From 593ce4aadf943eb69205569543a3f5e46f12049f Mon Sep 17 00:00:00 2001 From: Serghei Mihai Date: Thu, 22 Nov 2018 12:04:41 +0100 Subject: [PATCH] misc: allow authenticator autorun if only one available (#28216) --- src/authentic2/auth2_auth/auth2_ssl/authenticators.py | 3 +++ src/authentic2/views.py | 4 ++++ src/authentic2_auth_saml/authenticators.py | 3 +++ 3 files changed, 10 insertions(+) diff --git a/src/authentic2/auth2_auth/auth2_ssl/authenticators.py b/src/authentic2/auth2_auth/auth2_ssl/authenticators.py index 7be542d2..04f77ead 100644 --- a/src/authentic2/auth2_auth/auth2_ssl/authenticators.py +++ b/src/authentic2/auth2_auth/auth2_ssl/authenticators.py @@ -21,6 +21,9 @@ class SSLAuthenticator(BaseAuthenticator): def form(self): return django.forms.Form + def autorun(self, request): + return redirect_to_login(request, login_url='user_signin_ssl',) + def post(self, request, form, nonce, next_url): return redirect_to_login(request, login_url='user_signin_ssl',) diff --git a/src/authentic2/views.py b/src/authentic2/views.py index 23c87818..4c1be7c2 100644 --- a/src/authentic2/views.py +++ b/src/authentic2/views.py @@ -283,6 +283,10 @@ def login(request, template_name='authentic2/login.html', frontends = utils.get_backends('AUTH_FRONTENDS', request) + # if only one frontend available and it allow autologin run in + if len(frontends) == 1 and hasattr(frontends[0], 'autorun'): + return frontends[0].autorun(request) + blocks = [] registration_url = utils.get_registration_url( diff --git a/src/authentic2_auth_saml/authenticators.py b/src/authentic2_auth_saml/authenticators.py index 0c4ffd1d..474e7778 100644 --- a/src/authentic2_auth_saml/authenticators.py +++ b/src/authentic2_auth_saml/authenticators.py @@ -20,6 +20,9 @@ class SAMLAuthenticator(BaseAuthenticator): def name(self): return gettext_noop('SAML') + def autorun(self, request): + return redirect_to_login(request, login_url='mellon_login') + def login(self, request, *args, **kwargs): context = kwargs.pop('context', {}) submit_name = 'login-%s' % self.id -- 2.19.1