Rajoute un paramètre pour désactiver le LDAP
This commit is contained in:
parent
423dfcd2ec
commit
41752ac344
2 changed files with 8 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
||||||
LDAP_SERVER_URL = "ldaps://ldap.spi.ens.fr:636"
|
LDAP_SERVER_URL = "ldaps://ldap.spi.ens.fr:636"
|
||||||
AUTHENS_USE_OLDCAS = True
|
AUTHENS_USE_OLDCAS = True
|
||||||
AUTHENS_USE_PASSWORD = True
|
AUTHENS_USE_PASSWORD = True
|
||||||
|
USE_LDAP = True
|
||||||
# TODO: CAS_SERVER_URL
|
# TODO: CAS_SERVER_URL
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
"""Helper functions to get CAS metadata and create CAS accounts."""
|
"""Helper functions to get CAS metadata and create CAS accounts."""
|
||||||
|
|
||||||
|
import warnings
|
||||||
|
|
||||||
# TODO: make the python-ldap dependency optional
|
# TODO: make the python-ldap dependency optional
|
||||||
import ldap
|
import ldap
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
|
@ -24,6 +27,10 @@ def fetch_cas_account(cas_login):
|
||||||
if not cas_login.isalnum():
|
if not cas_login.isalnum():
|
||||||
raise ValueError("Illegal CAS login: {}".format(cas_login))
|
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_url = getattr(settings, "LDAP_SERVER_URL", default_conf.LDAP_SERVER_URL)
|
||||||
ldap_obj = ldap.initialize(ldap_url)
|
ldap_obj = ldap.initialize(ldap_url)
|
||||||
res = ldap_obj.search_s(
|
res = ldap_obj.search_s(
|
||||||
|
|
Loading…
Reference in a new issue