Skip to content

Commit 7340ddc

Browse files
authored
Merge pull request #1470 from itglob/master
added compatibility with a case-insensitive authentication provider
2 parents 76dc9dc + a7882b9 commit 7340ddc

File tree

6 files changed

+24
-4
lines changed

6 files changed

+24
-4
lines changed

DOCUMENTATION.md

+7
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,13 @@ Message displayed in the client when a password is needed.
786786

787787
Default: `Radicale - Password Required`
788788

789+
##### lc_username
790+
791+
Сonvert username to lowercase, must be true for case-insensitive auth
792+
providers like ldap, kerberos
793+
794+
Default: `False`
795+
789796
#### rights
790797

791798
##### type

config

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
# Message displayed in the client when a password is needed
7171
#realm = Radicale - Password Required
7272

73+
# Сonvert username to lowercase, must be true for case-insensitive auth providers
74+
#lc_username = False
75+
7376

7477
[rights]
7578

radicale/auth/__init__.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ def load(configuration: "config.Configuration") -> "BaseAuth":
4444

4545
class BaseAuth:
4646

47+
_lc_username: bool
48+
4749
def __init__(self, configuration: "config.Configuration") -> None:
4850
"""Initialize BaseAuth.
4951
@@ -53,6 +55,7 @@ def __init__(self, configuration: "config.Configuration") -> None:
5355
5456
"""
5557
self.configuration = configuration
58+
self._lc_username = configuration.get("auth", "lc_username")
5659

5760
def get_external_login(self, environ: types.WSGIEnviron) -> Union[
5861
Tuple[()], Tuple[str, str]]:
@@ -67,7 +70,7 @@ def get_external_login(self, environ: types.WSGIEnviron) -> Union[
6770
"""
6871
return ()
6972

70-
def login(self, login: str, password: str) -> str:
73+
def _login(self, login: str, password: str) -> str:
7174
"""Check credentials and map login to internal user
7275
7376
``login`` the login name
@@ -79,3 +82,6 @@ def login(self, login: str, password: str) -> str:
7982
"""
8083

8184
raise NotImplementedError
85+
86+
def login(self, login: str, password: str) -> str:
87+
return self._login(login, password).lower() if self._lc_username else self._login(login, password)

radicale/auth/htpasswd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def _autodetect(self, hash_value: str, password: str) -> bool:
127127
# assumed plaintext
128128
return self._plain(hash_value, password)
129129

130-
def login(self, login: str, password: str) -> str:
130+
def _login(self, login: str, password: str) -> str:
131131
"""Validate credentials.
132132
133133
Iterate through htpasswd credential file until login matches, extract

radicale/auth/none.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727

2828
class Auth(auth.BaseAuth):
2929

30-
def login(self, login: str, password: str) -> str:
30+
def _login(self, login: str, password: str) -> str:
3131
return login

radicale/config.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,11 @@ def _convert_to_bool(value: Any) -> bool:
177177
("delay", {
178178
"value": "1",
179179
"help": "incorrect authentication delay",
180-
"type": positive_float})])),
180+
"type": positive_float}),
181+
("lc_username", {
182+
"value": "False",
183+
"help": "convert username to lowercase, must be true for case-insensitive auth providers",
184+
"type": bool})])),
181185
("rights", OrderedDict([
182186
("type", {
183187
"value": "owner_only",

0 commit comments

Comments
 (0)