1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-09-06 20:10:56 +00:00

add auth/strip_domain option

This commit is contained in:
Peter Bieringer 2024-07-18 06:50:29 +02:00
parent f117fd06af
commit 13b1aaed39
5 changed files with 24 additions and 1 deletions

View file

@ -52,6 +52,7 @@ def load(configuration: "config.Configuration") -> "BaseAuth":
class BaseAuth:
_lc_username: bool
_strip_domain: bool
def __init__(self, configuration: "config.Configuration") -> None:
"""Initialize BaseAuth.
@ -63,6 +64,7 @@ class BaseAuth:
"""
self.configuration = configuration
self._lc_username = configuration.get("auth", "lc_username")
self._strip_domain = configuration.get("auth", "strip_domain")
def get_external_login(self, environ: types.WSGIEnviron) -> Union[
Tuple[()], Tuple[str, str]]:
@ -91,4 +93,8 @@ class BaseAuth:
raise NotImplementedError
def login(self, login: str, password: str) -> str:
return self._login(login, password).lower() if self._lc_username else self._login(login, password)
if self._lc_username:
login = login.lower()
if self._strip_domain:
login = login.split('@')[0]
return self._login(login, password)