Allow attach custom auth handler

This commit is contained in:
Sergey Fursov
2013-12-28 13:31:32 +04:00
parent dca10fa14e
commit a91a7790c5
7 changed files with 75 additions and 25 deletions

View File

@ -34,13 +34,17 @@ def load():
log.LOGGER.debug("Authentication type is %s" % auth_type)
if auth_type == "None":
return None
elif auth_type == 'custom':
auth_module = config.get("auth", "custom_handler")
__import__(auth_module)
module = sys.modules[auth_module]
else:
root_module = __import__(
"auth.%s" % auth_type, globals=globals(), level=2)
module = getattr(root_module, auth_type)
# Override auth.is_authenticated
sys.modules[__name__].is_authenticated = module.is_authenticated
return module
# Override auth.is_authenticated
sys.modules[__name__].is_authenticated = module.is_authenticated
return module
def is_authenticated(user, password):

View File

@ -55,6 +55,7 @@ INITIAL_CONFIG = {
"stock": "utf-8"},
"auth": {
"type": "None",
"custom_handler": "",
"htpasswd_filename": "/etc/radicale/users",
"htpasswd_encryption": "crypt",
"imap_hostname": "localhost",