Rajoute la possibilité d'autoriser l'accès aux membres de staffs, avec une promotion valant 0
This commit is contained in:
parent
8492d95040
commit
f362bb1a60
3 changed files with 15 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
LDAP_SERVER_URL = "ldaps://ldap.spi.ens.fr:636"
|
||||
AUTHENS_USE_OLDCAS = True
|
||||
AUTHENS_USE_PASSWORD = True
|
||||
AUTHENS_ALLOW_STAFF = False
|
||||
# TODO: CAS_SERVER_URL
|
||||
|
|
|
@ -3,6 +3,10 @@ from urllib.parse import urlunparse
|
|||
|
||||
from cas import CASClient
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from authens import conf as default_conf
|
||||
|
||||
|
||||
def get_cas_client(request):
|
||||
"""Return a CAS client configured for SPI's CAS."""
|
||||
|
@ -26,6 +30,15 @@ def parse_entrance_year(home_dir):
|
|||
return None
|
||||
|
||||
dirs = home_dir.split("/")
|
||||
|
||||
allow_staff = getattr(
|
||||
settings, "AUTHENS_ALLOW_STAFF", default_conf.AUTHENS_ALLOW_STAFF
|
||||
)
|
||||
|
||||
# The staff members have an entrance year set to 0
|
||||
if allow_staff and dirs[:3] == ["", "users", "staffs"]:
|
||||
return 0
|
||||
|
||||
if len(dirs) < 3 or not dirs[2].isdecimal() or dirs[1] != "users":
|
||||
raise ValueError("Invalid home directory: {}".format(home_dir))
|
||||
|
||||
|
|
Loading…
Reference in a new issue