first release
This commit is contained in:
parent
75c66227d1
commit
cae29d263f
0
collection/.Radicale.lock
Normal file
0
collection/.Radicale.lock
Normal file
20
config
Normal file
20
config
Normal file
@ -0,0 +1,20 @@
|
||||
[server]
|
||||
hosts = 0.0.0.0:5232
|
||||
max_connections = 50
|
||||
dns_lookup = True
|
||||
|
||||
|
||||
[auth]
|
||||
type = radicale_stamm_auth
|
||||
server = https://auth.stamm.me
|
||||
client_id = 02fcf12f66a73e0d816677a6d1c669b383ac4e656a3f02ae262207cb236a8bf9f973c6ff194f27e6f40ac53a3001949c8f2de66d586bdd70991ada25f68591e8
|
||||
client_secret = fe9696c800bf59346e895ae8e95edf8b18b14f5c305a53aca1d66b2b6f1a91c4a324fb7d910ede0f691087d99649e28fc606bf9312f2a7c9f65f06f8c2bbb49d5663c2306c5f3446f335f03f3371dea61fa96815376147e30d7dc0b06afe25e2a02f7aec42d07bc6e89f2ef6bcb664c4d6bd867a7f4a67e9fac7e0568440fb409535927703f5c2272624918f7be9f1e34a7178a9d0ed8c0e39ed2b587436087fc74d1b9917c30c803940240837e429166aba6935ffe4c770f7bf45201296ecc9
|
||||
|
||||
[rights]
|
||||
type = owner_only
|
||||
|
||||
[storage]
|
||||
filesystem_folder = .\\collection
|
||||
|
||||
[logging]
|
||||
debug = True
|
@ -1,34 +1,38 @@
|
||||
from radicale.auth import BaseAuth
|
||||
import urllib
|
||||
import urllib.request
|
||||
import json
|
||||
|
||||
|
||||
class Auth(BaseAuth):
|
||||
def _generateBaseUri(endpoint)
|
||||
def generate_base_uri(self, endpoint):
|
||||
server = self.configuration.get("auth", "server")
|
||||
id = self.configuration.get("auth", "client_id")
|
||||
secret = self.configuration.get("auth", "client_secret")
|
||||
return "{}{}?client_id={}&client_secret={}".format(server, endpoint, id, secret)
|
||||
|
||||
def is_authenticated(self, user, password):
|
||||
if user == None
|
||||
if user is None:
|
||||
return False
|
||||
main_uri = self._generateBaseUri(
|
||||
main_uri = self.generate_base_uri(
|
||||
"/client/check_pw") + "&uuid=" + user + "&password=" + password
|
||||
req = urllib.request.urlopen(main_uri, data=None)
|
||||
jsons = req.read()
|
||||
data = json.loads(jsons)
|
||||
print(data["username"], data["uuid"])
|
||||
if data["error"]
|
||||
print(data)
|
||||
if "error" in data:
|
||||
return False
|
||||
return True
|
||||
|
||||
def map_login_to_user(self, login)
|
||||
def map_login_to_user(self, login):
|
||||
# Get uuid from username
|
||||
main_uri = self._generateBaseUri("/client/uuid") + "&username=" + login
|
||||
if login is None or login is "":
|
||||
return None
|
||||
main_uri = self.generate_base_uri(
|
||||
"/client/uuid") + "&username=" + login
|
||||
req = urllib.request.urlopen(main_uri, data=None)
|
||||
jsons = req.read()
|
||||
data = json.loads(jsons)
|
||||
print(data["error"], data["username"], data["uuid"])
|
||||
if data["error"] != None
|
||||
print(data)
|
||||
if "error" in data:
|
||||
return None
|
||||
return data["uuid"]
|
Loading…
Reference in New Issue
Block a user