diff --git a/cof/settings/bds_prod.py b/cof/settings/bds_prod.py index abd43ca9..31e986f8 100644 --- a/cof/settings/bds_prod.py +++ b/cof/settings/bds_prod.py @@ -13,20 +13,26 @@ from .common import BASE_DIR, INSTALLED_APPS ALLOWED_HOSTS = ["bds.ens.fr", "www.bds.ens.fr", "dev.cof.ens.fr"] -INSTALLED_APPS += ["bds", "events", "clubs"] +INSTALLED_APPS += ["bds", "events", "clubs", "authens"] -STATIC_ROOT = os.path.join( - os.path.dirname(os.path.dirname(BASE_DIR)), "public", "gestion", "static" -) - -STATIC_URL = "/gestion/static/" -MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "media") -MEDIA_URL = "/gestion/media/" +STATIC_ROOT = "/srv/bds.ens.fr/public/gestion2/static" +STATIC_URL = "/gestion2/static/" +MEDIA_ROOT = "/srv/bds.ens.fr/gestion2/media" +MEDIA_URL = "/gestion2/media/" # --- # Auth-related stuff # --- -LOGIN_URL = "admin:login" +AUTHENTICATION_BACKENDS = [ + "django.contrib.auth.backends.ModelBackend", + "authens.backends.ENSCASBackend", + "authens.backends.OldCASBackend", +] + +AUTHENS_USE_OLDCAS = False + +LOGIN_URL = "authens:login" LOGIN_REDIRECT_URL = "bds:home" +LOGOUT_REDIRECT_URL = "bds:home" diff --git a/cof/settings/cof_prod.py b/cof/settings/cof_prod.py index 180e92a6..0f73841e 100644 --- a/cof/settings/cof_prod.py +++ b/cof/settings/cof_prod.py @@ -18,6 +18,11 @@ from .common import ( # COF-specific secrets # --- +REDIS_PASSWD = import_secret("REDIS_PASSWD") +REDIS_DB = import_secret("REDIS_DB") +REDIS_HOST = import_secret("REDIS_HOST") +REDIS_PORT = import_secret("REDIS_PORT") + RECAPTCHA_PUBLIC_KEY = import_secret("RECAPTCHA_PUBLIC_KEY") RECAPTCHA_PRIVATE_KEY = import_secret("RECAPTCHA_PRIVATE_KEY") KFETOPEN_TOKEN = import_secret("KFETOPEN_TOKEN") @@ -112,6 +117,43 @@ AUTHENTICATION_BACKENDS += [ LOGIN_URL = "cof-login" LOGIN_REDIRECT_URL = "home" +# --- +# Cache settings +# --- + +CACHES = { + "default": { + "BACKEND": "redis_cache.RedisCache", + "LOCATION": "redis://:{passwd}@{host}:{port}/{db}".format( + passwd=REDIS_PASSWD, host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB + ), + } +} + + +# --- +# Channels settings +# --- + +CHANNEL_LAYERS = { + "default": { + "BACKEND": "asgi_redis.RedisChannelLayer", + "CONFIG": { + "hosts": [ + ( + "redis://:{passwd}@{host}:{port}/{db}".format( + passwd=REDIS_PASSWD, + host=REDIS_HOST, + port=REDIS_PORT, + db=REDIS_DB, + ) + ) + ] + }, + "ROUTING": "cof.routing.routing", + } +} + # --- # reCAPTCHA settings diff --git a/cof/settings/common.py b/cof/settings/common.py index 0c34bf67..4636ace3 100644 --- a/cof/settings/common.py +++ b/cof/settings/common.py @@ -41,11 +41,6 @@ DBNAME = import_secret("DBNAME") DBUSER = import_secret("DBUSER") DBPASSWD = import_secret("DBPASSWD") -REDIS_PASSWD = import_secret("REDIS_PASSWD") -REDIS_DB = import_secret("REDIS_DB") -REDIS_HOST = import_secret("REDIS_HOST") -REDIS_PORT = import_secret("REDIS_PORT") - LDAP_SERVER_URL = import_secret("LDAP_SERVER_URL") @@ -146,40 +141,3 @@ CAS_LOGIN_MSG = None CAS_IGNORE_REFERER = True CAS_REDIRECT_URL = "/" CAS_EMAIL_FORMAT = "%s@clipper.ens.fr" - -# --- -# Cache settings -# --- - -CACHES = { - "default": { - "BACKEND": "redis_cache.RedisCache", - "LOCATION": "redis://:{passwd}@{host}:{port}/{db}".format( - passwd=REDIS_PASSWD, host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB - ), - } -} - - -# --- -# Channels settings -# --- - -CHANNEL_LAYERS = { - "default": { - "BACKEND": "asgi_redis.RedisChannelLayer", - "CONFIG": { - "hosts": [ - ( - "redis://:{passwd}@{host}:{port}/{db}".format( - passwd=REDIS_PASSWD, - host=REDIS_HOST, - port=REDIS_PORT, - db=REDIS_DB, - ) - ) - ] - }, - "ROUTING": "cof.routing.routing", - } -} diff --git a/cof/urls.py b/cof/urls.py index fe7bf5d1..af7501d1 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -144,6 +144,9 @@ if "events" in settings.INSTALLED_APPS: # → rename this when the old events system is out urlpatterns += [path("event_v2/", include("events.urls"))] +if "authens" in settings.INSTALLED_APPS: + urlpatterns.append(path("authens/", include("authens.urls"))) + if "debug_toolbar" in settings.INSTALLED_APPS: import debug_toolbar diff --git a/requirements.txt b/requirements.txt index 9fbc3e06..bf58d8f4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,3 +17,4 @@ wagtailmenus==3.* wagtail-modeltranslation==0.10.* django-cors-headers==2.2.0 django-js-reverse +authens==0.1b0