Skip to content

Commit

Permalink
more adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
ciur committed Feb 16, 2024
1 parent 080661a commit d9d7116
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 7 additions & 1 deletion auth_server/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@ async def ldap_auth(
username: str,
password: str
) -> schemas.User | None:
client = LDAPAuth(username, password)
client = LDAPAuth(
url=settings.papermerge__auth__ldap_url,
username=username,
password=password,
user_dn_format=settings.papermerge__auth__ldap_user_dn_format,
use_ssl=settings.papermerge__auth__ldap_use_ssl
)

try:
await client.signin()
Expand Down
4 changes: 2 additions & 2 deletions auth_server/backends/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class LDAPAuth:
name: str = 'ldap'

def __init__(self,
uri: str,
url: str,
username: str,
password: str,
user_dn_format: str,
use_ssl: bool = True,
):
self._username = username
self._password = password
self._uri = uri
self._url = url
self._user_dn_format = user_dn_format
self._use_ssl = use_ssl

Expand Down
7 changes: 4 additions & 3 deletions auth_server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ class Settings(BaseSettings):
papermerge__auth__google_client_secret: str | None = None
papermerge__auth__github_client_secret: str | None = None

papermerge__auth__ldap_uri: str | None = None # e.g. ldap.trusel.net
papermerge__auth__ldap_url: str | None = None # e.g. ldap.trusel.net
papermerge__auth__ldap_use_ssl: bool = True
# e.g. uid={username},ou=People,dc=ldap,dc=trusel,dc=net
papermerge__auth__ldap_user_dn_format: str | None = None
papermerge__auth__ldap_email_attr: str | None = None # e.g. email
# LDAP Entry attribute name for the email
papermerge__auth__ldap_email_attr: str = 'mail'
# if there is an error retrieving ldap_email_attr, the
# fallback user email will be set to username@<email-domain-fallback>
papermerge__auth__ldap_user_email_domain_fallback: str = 'example.com'
papermerge__auth__ldap_user_email_domain_fallback: str = 'example-ldap.com'


@lru_cache()
Expand Down

0 comments on commit d9d7116

Please sign in to comment.