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

Use module-wide logger and remove logging config

This commit is contained in:
Unrud 2018-08-16 07:59:55 +02:00
parent 6c9299cf16
commit 54b9995e22
15 changed files with 176 additions and 274 deletions

View file

@ -60,11 +60,13 @@ import hmac
import os
from importlib import import_module
from radicale.log import logger
INTERNAL_TYPES = ("None", "none", "remote_user", "http_x_remote_user",
"htpasswd")
def load(configuration, logger):
def load(configuration):
"""Load the authentication manager chosen in configuration."""
auth_type = configuration.get("auth", "type")
if auth_type in ("None", "none"): # DEPRECATED: use "none"
@ -82,13 +84,12 @@ def load(configuration, logger):
raise RuntimeError("Failed to load authentication module %r: %s" %
(auth_type, e)) from e
logger.info("Authentication type is %r", auth_type)
return class_(configuration, logger)
return class_(configuration)
class BaseAuth:
def __init__(self, configuration, logger):
def __init__(self, configuration):
self.configuration = configuration
self.logger = logger
def get_external_login(self, environ):
"""Optionally provide the login and password externally.
@ -149,8 +150,8 @@ class NoneAuth(BaseAuth):
class Auth(BaseAuth):
def __init__(self, configuration, logger):
super().__init__(configuration, logger)
def __init__(self, configuration):
super().__init__(configuration)
self.filename = os.path.expanduser(
configuration.get("auth", "htpasswd_filename"))
self.encryption = configuration.get("auth", "htpasswd_encryption")