1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-06-26 16:45:52 +00:00

Map logins to internal users in Auth module

This makes it possible to implement #349 as a Auth module. Another use case would be to encode usernames that contain characters unsupported by the file system.
This commit is contained in:
Unrud 2016-08-30 23:13:33 +02:00
parent 5d9485d660
commit 689e5c9dd5
2 changed files with 18 additions and 8 deletions

View file

@ -65,12 +65,12 @@ def load(configuration, logger):
auth_type = configuration.get("auth", "type")
logger.debug("Authentication type is %s", auth_type)
if auth_type == "None":
return lambda user, password: True
class_ = NoneAuth
elif auth_type == "htpasswd":
return Auth(configuration, logger).is_authenticated
class_ = Auth
else:
module = import_module(auth_type)
return module.Auth(configuration, logger).is_authenticated
class_ = import_module(auth_type).Auth
return class_(configuration, logger)
class BaseAuth:
@ -88,6 +88,15 @@ class BaseAuth:
"""
raise NotImplementedError
def map_login_to_user(self, login):
"""Map login to internal username."""
return login
class NoneAuth(BaseAuth):
def is_authenticated(self, user, password):
return True
class Auth(BaseAuth):
def __init__(self, configuration, logger):