diff --git a/authens/conf.py b/authens/conf.py
index 04b5cb0..94d8cf5 100644
--- a/authens/conf.py
+++ b/authens/conf.py
@@ -1,2 +1,3 @@
LDAP_SERVER_URL = "ldaps://ldap.spi.ens.fr:636"
+AUTHENS_USE_OLDCAS = True
# TODO: CAS_SERVER_URL
diff --git a/authens/templates/authens/login_switch.html b/authens/templates/authens/login_switch.html
index 50d38e3..62e9d7d 100644
--- a/authens/templates/authens/login_switch.html
+++ b/authens/templates/authens/login_switch.html
@@ -13,8 +13,10 @@
{% trans "Mot de passe" %}
-
- {% trans "Vieilleux" %}
-
+ {% if oldcas %}
+
+ {% trans "Vieilleux" %}
+
+ {% endif %}
{% endblock %}
diff --git a/authens/urls.py b/authens/urls.py
index 28dcbfa..18e2aee 100644
--- a/authens/urls.py
+++ b/authens/urls.py
@@ -1,13 +1,13 @@
+from django.conf import settings
from django.urls import path
-from authens import views
+from authens import conf as default_conf, views
app_name = "authens"
urlpatterns = [
path("login/choose", views.LoginSwitchView.as_view(), name="login"),
path("login/cas", views.CASLoginView.as_view(), name="login.cas"),
path("login/pwd", views.PasswordLoginView.as_view(), name="login.pwd"),
- path("login/oldcas", views.OldCASLoginView.as_view(), name="login.oldcas"),
path("logout", views.LogoutView.as_view(), name="logout"),
path("reset/pwd", views.PasswordResetView.as_view(), name="reset.pwd"),
path(
@@ -16,3 +16,8 @@ urlpatterns = [
name="reset.pwd.confirm",
),
]
+
+if getattr(settings, "AUTHENS_USE_OLDCAS", default_conf.AUTHENS_USE_OLDCAS):
+ urlpatterns += (
+ path("login/oldcas", views.OldCASLoginView.as_view(), name="login.oldcas"),
+ )
diff --git a/authens/views.py b/authens/views.py
index 70134ad..fc63867 100644
--- a/authens/views.py
+++ b/authens/views.py
@@ -11,6 +11,7 @@ from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView, View
+from authens import conf as default_conf
from authens.forms import OldCASAuthForm
from authens.utils import get_cas_client
@@ -47,7 +48,15 @@ class LoginSwitchView(NextPageMixin, TemplateView):
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
- ctx["next"] = self.get_next_url()
+
+ ctx.update(
+ {
+ "next": self.get_next_url(),
+ "oldcas": getattr(
+ settings, "AUTHENS_USE_OLDCAS", default_conf.AUTHENS_USE_OLDCAS
+ ),
+ }
+ )
return ctx
diff --git a/example_site/example_site/settings.py b/example_site/example_site/settings.py
index fdb8240..8ec4365 100644
--- a/example_site/example_site/settings.py
+++ b/example_site/example_site/settings.py
@@ -130,6 +130,7 @@ AUTHENTICATION_BACKENDS = [
LOGIN_URL = reverse_lazy("authens:login")
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
+AUTHENS_USE_OLDCAS = False
# This is cosmetic
LOGIN_REDIRECT_URL = reverse_lazy("home")