From 92ddb6c25e58dda5725e35b424e4e51868002ca0 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 29 Nov 2022 16:32:00 +0100 Subject: [PATCH 2/3] auth_oidc: make autorun go directly to the OP (#27135) --- src/authentic2_auth_oidc/models.py | 8 ++++---- tests/test_auth_oidc.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/authentic2_auth_oidc/models.py b/src/authentic2_auth_oidc/models.py index f39af972..8bac71a2 100644 --- a/src/authentic2_auth_oidc/models.py +++ b/src/authentic2_auth_oidc/models.py @@ -31,7 +31,7 @@ from authentic2.apps.authenticators.models import ( AuthenticatorRelatedObjectBase, BaseAuthenticator, ) -from authentic2.utils.misc import make_url, redirect_to_login +from authentic2.utils.misc import make_url from authentic2.utils.template import validate_template from . import managers @@ -233,9 +233,9 @@ class OIDCProvider(BaseAuthenticator): return '' % self.issuer def autorun(self, request, block_id, next_url): - return redirect_to_login( - request, login_url='oidc-login', kwargs={'pk': self.pk}, params={'next': next_url} - ) + from . import views + + return views.oidc_login(request, pk=self.pk, next_url=next_url) def login(self, request, *args, **kwargs): context = kwargs.get('context', {}).copy() diff --git a/tests/test_auth_oidc.py b/tests/test_auth_oidc.py index 58c57a27..fd9efecb 100644 --- a/tests/test_auth_oidc.py +++ b/tests/test_auth_oidc.py @@ -492,7 +492,7 @@ def test_login_autorun(oidc_provider, app, settings): slug='password-authenticator', defaults={'enabled': False} ) response = app.get('/login/', status=302) - assert response['Location'] == '/accounts/oidc/login/%s/?next=/' % oidc_provider.pk + assert response['Location'].startswith('https://server.example.com/authorize') def test_sso(app, caplog, code, oidc_provider, oidc_provider_jwkset, hooks): -- 2.37.2