Add is_authenticated2 to BaseAuth
Adds the ``login`` argument.
This commit is contained in:
parent
106aeae781
commit
8be792280a
@ -446,7 +446,8 @@ class Application:
|
|||||||
self.logger.info("Refused unsafe username: %r", user)
|
self.logger.info("Refused unsafe username: %r", user)
|
||||||
is_authenticated = False
|
is_authenticated = False
|
||||||
else:
|
else:
|
||||||
is_authenticated = self.Auth.is_authenticated(user, password)
|
is_authenticated = self.Auth.is_authenticated2(login, user,
|
||||||
|
password)
|
||||||
if not is_authenticated:
|
if not is_authenticated:
|
||||||
self.logger.info("Failed login attempt: %r", user)
|
self.logger.info("Failed login attempt: %r", user)
|
||||||
# Random delay to avoid timing oracles and bruteforce attacks
|
# Random delay to avoid timing oracles and bruteforce attacks
|
||||||
|
@ -102,13 +102,23 @@ class BaseAuth:
|
|||||||
"""
|
"""
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
def is_authenticated(self, user, password):
|
def is_authenticated2(self, login, user, password):
|
||||||
"""Validate credentials.
|
"""Validate credentials.
|
||||||
|
|
||||||
|
``login`` the login name
|
||||||
|
|
||||||
``user`` the user from ``map_login_to_user(login)``.
|
``user`` the user from ``map_login_to_user(login)``.
|
||||||
|
|
||||||
``password`` the login password
|
``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
|
raise NotImplementedError
|
||||||
|
|
||||||
@ -119,7 +129,7 @@ class BaseAuth:
|
|||||||
|
|
||||||
Returns a string with the user name.
|
Returns a string with the user name.
|
||||||
If a login can't be mapped to an user, return ``login`` and
|
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
|
return login
|
||||||
|
Loading…
Reference in New Issue
Block a user