Merge branch 'Aufinal/oldcas_option' into 'master'
Rend l'auth vieilleux optionnelle See merge request klub-dev-ens/authens!18
This commit is contained in:
commit
788924b942
5 changed files with 24 additions and 6 deletions
|
@ -1,2 +1,3 @@
|
||||||
LDAP_SERVER_URL = "ldaps://ldap.spi.ens.fr:636"
|
LDAP_SERVER_URL = "ldaps://ldap.spi.ens.fr:636"
|
||||||
|
AUTHENS_USE_OLDCAS = True
|
||||||
# TODO: CAS_SERVER_URL
|
# TODO: CAS_SERVER_URL
|
||||||
|
|
|
@ -13,8 +13,10 @@
|
||||||
<a class="big-button exte" href="{% url "authens:login.pwd" %}?next={{ next| urlencode }}">
|
<a class="big-button exte" href="{% url "authens:login.pwd" %}?next={{ next| urlencode }}">
|
||||||
{% trans "Mot de passe" %}
|
{% trans "Mot de passe" %}
|
||||||
</a>
|
</a>
|
||||||
|
{% if oldcas %}
|
||||||
<a class="big-button oldcas" href="{% url "authens:login.oldcas" %}?next={{ next| urlencode }}">
|
<a class="big-button oldcas" href="{% url "authens:login.oldcas" %}?next={{ next| urlencode }}">
|
||||||
{% trans "Vieilleux" %}
|
{% trans "Vieilleux" %}
|
||||||
</a>
|
</a>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
|
from django.conf import settings
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from authens import views
|
from authens import conf as default_conf, views
|
||||||
|
|
||||||
app_name = "authens"
|
app_name = "authens"
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("login/choose", views.LoginSwitchView.as_view(), name="login"),
|
path("login/choose", views.LoginSwitchView.as_view(), name="login"),
|
||||||
path("login/cas", views.CASLoginView.as_view(), name="login.cas"),
|
path("login/cas", views.CASLoginView.as_view(), name="login.cas"),
|
||||||
path("login/pwd", views.PasswordLoginView.as_view(), name="login.pwd"),
|
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("logout", views.LogoutView.as_view(), name="logout"),
|
||||||
path("reset/pwd", views.PasswordResetView.as_view(), name="reset.pwd"),
|
path("reset/pwd", views.PasswordResetView.as_view(), name="reset.pwd"),
|
||||||
path(
|
path(
|
||||||
|
@ -16,3 +16,8 @@ urlpatterns = [
|
||||||
name="reset.pwd.confirm",
|
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"),
|
||||||
|
)
|
||||||
|
|
|
@ -11,6 +11,7 @@ from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.views.generic import TemplateView, View
|
from django.views.generic import TemplateView, View
|
||||||
|
|
||||||
|
from authens import conf as default_conf
|
||||||
from authens.forms import OldCASAuthForm
|
from authens.forms import OldCASAuthForm
|
||||||
from authens.utils import get_cas_client
|
from authens.utils import get_cas_client
|
||||||
|
|
||||||
|
@ -47,7 +48,15 @@ class LoginSwitchView(NextPageMixin, TemplateView):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
ctx = super().get_context_data(**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
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -130,6 +130,7 @@ AUTHENTICATION_BACKENDS = [
|
||||||
LOGIN_URL = reverse_lazy("authens:login")
|
LOGIN_URL = reverse_lazy("authens:login")
|
||||||
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||||
|
|
||||||
|
AUTHENS_USE_OLDCAS = False
|
||||||
|
|
||||||
# This is cosmetic
|
# This is cosmetic
|
||||||
LOGIN_REDIRECT_URL = reverse_lazy("home")
|
LOGIN_REDIRECT_URL = reverse_lazy("home")
|
||||||
|
|
Loading…
Reference in a new issue