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

Auth: Introduce login(login, password) method

This deprecates map_login_to_user, is_authenticated and is_authenticated2
This commit is contained in:
Unrud 2018-04-30 00:18:36 +02:00
parent e96fa64fa6
commit e73270bbe5
2 changed files with 40 additions and 33 deletions

View file

@ -102,14 +102,26 @@ class BaseAuth:
"""
return ()
def is_authenticated2(self, login, user, password):
"""Validate credentials.
def login(self, login, password):
"""Check credentials and map login to internal user
``login`` the login name
``user`` the user from ``map_login_to_user(login)``.
``password`` the password
``password`` the login password
Returns the user name or ``""`` for invalid credentials.
"""
user = self.map_login_to_user(login)
if user and self.is_authenticated2(login, user, password):
return user
return ""
def is_authenticated2(self, login, user, password):
"""Validate credentials.
DEPRECATED: use ``login`` instead
"""
return self.is_authenticated(user, password)
@ -117,7 +129,7 @@ class BaseAuth:
def is_authenticated(self, user, password):
"""Validate credentials.
DEPRECATED: use ``is_authenticated2`` instead
DEPRECATED: use ``login`` instead
"""
raise NotImplementedError
@ -125,11 +137,7 @@ class BaseAuth:
def map_login_to_user(self, login):
"""Map login name to internal user.
``login`` the login name, ``""`` for anonymous users
Returns a string with the user name.
If a login can't be mapped to an user, return ``login`` and
return ``False`` in ``is_authenticated2(...)``.
DEPRECATED: use ``login`` instead
"""
return login