From 8be792280aff9c09be08f5124c241e9ed222c52c Mon Sep 17 00:00:00 2001 From: Unrud Date: Sun, 17 Sep 2017 14:03:52 +0200 Subject: [PATCH] Add is_authenticated2 to BaseAuth Adds the ``login`` argument. --- radicale/__init__.py | 3 ++- radicale/auth.py | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index 08704c0..e20dde5 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -446,7 +446,8 @@ class Application: self.logger.info("Refused unsafe username: %r", user) is_authenticated = False else: - is_authenticated = self.Auth.is_authenticated(user, password) + is_authenticated = self.Auth.is_authenticated2(login, user, + password) if not is_authenticated: self.logger.info("Failed login attempt: %r", user) # Random delay to avoid timing oracles and bruteforce attacks diff --git a/radicale/auth.py b/radicale/auth.py index 64219d7..fc5d425 100644 --- a/radicale/auth.py +++ b/radicale/auth.py @@ -102,13 +102,23 @@ class BaseAuth: """ return () - def is_authenticated(self, user, password): + def is_authenticated2(self, login, user, password): """Validate credentials. + ``login`` the login name + ``user`` the user from ``map_login_to_user(login)``. ``password`` the login password + """ + return self.is_authenticated(user, password) + + def is_authenticated(self, user, password): + """Validate credentials. + + DEPRECATED: use ``is_authenticated2`` instead + """ raise NotImplementedError @@ -119,7 +129,7 @@ class BaseAuth: Returns a string with the user name. If a login can't be mapped to an user, return ``login`` and - return ``False`` in ``is_authenticated(...)``. + return ``False`` in ``is_authenticated2(...)``. """ return login