diff --git a/collection/.Radicale.lock b/collection/.Radicale.lock new file mode 100644 index 0000000..e69de29 diff --git a/config b/config new file mode 100644 index 0000000..3a84f82 --- /dev/null +++ b/config @@ -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 diff --git a/.vscode/.ropeproject/config.py b/plugins/.vscode/.ropeproject/config.py similarity index 100% rename from .vscode/.ropeproject/config.py rename to plugins/.vscode/.ropeproject/config.py diff --git a/.vscode/.ropeproject/objectdb b/plugins/.vscode/.ropeproject/objectdb similarity index 100% rename from .vscode/.ropeproject/objectdb rename to plugins/.vscode/.ropeproject/objectdb diff --git a/.vscode/settings.json b/plugins/.vscode/settings.json similarity index 100% rename from .vscode/settings.json rename to plugins/.vscode/settings.json diff --git a/radicale_stamm_auth/__init__.py b/plugins/radicale_stamm_auth/__init__.py similarity index 63% rename from radicale_stamm_auth/__init__.py rename to plugins/radicale_stamm_auth/__init__.py index 6c9e4a9..f11b84a 100644 --- a/radicale_stamm_auth/__init__.py +++ b/plugins/radicale_stamm_auth/__init__.py @@ -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) - # Get uuid from username - main_uri = self._generateBaseUri("/client/uuid") + "&username=" + login + def map_login_to_user(self, login): + # Get uuid from username + 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"] diff --git a/radicale_stamm_auth/setup.py b/plugins/setup.py similarity index 100% rename from radicale_stamm_auth/setup.py rename to plugins/setup.py diff --git a/test.py b/plugins/test.py similarity index 100% rename from test.py rename to plugins/test.py