mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 07:29:17 +02:00
Implement LDAP authentication
This commit is contained in:
parent
6ed5740f6f
commit
4ce46ff2a0
17 changed files with 232 additions and 15 deletions
|
@ -1,3 +1,5 @@
|
|||
import unicodedata
|
||||
import re
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
|
@ -32,3 +34,21 @@ def clean_wsgi_headers(raw_headers):
|
|||
cleaned[cleaned_header] = value
|
||||
|
||||
return cleaned
|
||||
|
||||
|
||||
def slugify_username(username):
|
||||
"""
|
||||
Given a username such as "hello M. world", returns a username
|
||||
suitable for federation purpose (hello_M_world).
|
||||
|
||||
Preserves the original case.
|
||||
|
||||
Code is borrowed from django's slugify function.
|
||||
"""
|
||||
|
||||
value = str(username)
|
||||
value = (
|
||||
unicodedata.normalize("NFKD", value).encode("ascii", "ignore").decode("ascii")
|
||||
)
|
||||
value = re.sub(r"[^\w\s-]", "", value).strip()
|
||||
return re.sub(r"[-\s]+", "_", value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue