first commit
This commit is contained in:
34
radicale_stamm_auth/__init__.py
Normal file
34
radicale_stamm_auth/__init__.py
Normal file
@ -0,0 +1,34 @@
|
||||
from radicale.auth import BaseAuth
|
||||
import urllib
|
||||
|
||||
|
||||
class Auth(BaseAuth):
|
||||
def _generateBaseUri(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
|
||||
return False
|
||||
main_uri = self._generateBaseUri(
|
||||
"/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"]
|
||||
return False
|
||||
return True
|
||||
|
||||
def map_login_to_user(self, login)
|
||||
# Get uuid from username
|
||||
main_uri = self._generateBaseUri("/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
|
||||
return None
|
||||
return data["uuid"]
|
5
radicale_stamm_auth/setup.py
Normal file
5
radicale_stamm_auth/setup.py
Normal file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from distutils.core import setup
|
||||
|
||||
setup(name="radicale_stamm_auth", packages=["radicale_stamm_auth"])
|
Reference in New Issue
Block a user