Compare commits
3 commits
master
...
thubrecht/
Author | SHA1 | Date | |
---|---|---|---|
54e4d28d0c | |||
41752ac344 | |||
423dfcd2ec |
3 changed files with 10 additions and 6 deletions
|
@ -1,4 +1,5 @@
|
|||
LDAP_SERVER_URL = "ldaps://ldap.spi.ens.fr:636"
|
||||
AUTHENS_USE_OLDCAS = True
|
||||
AUTHENS_USE_PASSWORD = True
|
||||
USE_LDAP = True
|
||||
# TODO: CAS_SERVER_URL
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
"""Helper functions to get CAS metadata and create CAS accounts."""
|
||||
|
||||
import warnings
|
||||
|
||||
# TODO: make the python-ldap dependency optional
|
||||
import ldap
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
|
@ -24,6 +27,10 @@ def fetch_cas_account(cas_login):
|
|||
if not cas_login.isalnum():
|
||||
raise ValueError("Illegal CAS login: {}".format(cas_login))
|
||||
|
||||
if not getattr(settings, "USE_LDAP", default_conf.USE_LDAP):
|
||||
warnings.warn("Use of LDAP is disabled", RuntimeWarning)
|
||||
return None
|
||||
|
||||
ldap_url = getattr(settings, "LDAP_SERVER_URL", default_conf.LDAP_SERVER_URL)
|
||||
ldap_obj = ldap.initialize(ldap_url)
|
||||
res = ldap_obj.search_s(
|
||||
|
|
|
@ -10,13 +10,9 @@ ignore =
|
|||
W503
|
||||
|
||||
[isort]
|
||||
# For black compat: https://github.com/ambv/black#how-black-wraps-lines
|
||||
profile = black
|
||||
combine_as_imports = true
|
||||
default_section = THIRDPARTY
|
||||
force_grid_wrap = 0
|
||||
include_trailing_comma = true
|
||||
known_django = django
|
||||
known_first_party = authens,tests
|
||||
line_length = 88
|
||||
multi_line_output = 3
|
||||
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
|
||||
sections = FUTURE,STDLIB,THIRDPARTY,DJANGO,FIRSTPARTY,LOCALFOLDER
|
||||
|
|
Loading…
Reference in a new issue