0001-misc-add-next_url-parameter-to-Authenticator.autorun.patch
src/authentic2/views.py | ||
---|---|---|
415 | 415 |
if hasattr(authenticator, 'autorun'): |
416 | 416 |
if 'message' in token: |
417 | 417 |
messages.info(request, token['message']) |
418 |
return authenticator.autorun(request, block.get('id'))
|
|
418 |
return authenticator.autorun(request, block_id=block.get('id'), next_url=redirect_to)
|
|
419 | 419 | |
420 | 420 |
context.update( |
421 | 421 |
{ |
src/authentic2_auth_fc/models.py | ||
---|---|---|
118 | 118 |
else: |
119 | 119 |
return 'https://app.franceconnect.gouv.fr/api/v1/logout' |
120 | 120 | |
121 |
def autorun(self, request, block_id): |
|
122 |
return views.LoginOrLinkView.as_view(display_message_on_redirect=True)(request) |
|
121 |
def autorun(self, request, block_id, next_url):
|
|
122 |
return views.LoginOrLinkView.as_view(display_message_on_redirect=True)(request, next_url=next_url)
|
|
123 | 123 | |
124 | 124 |
def login(self, request, *args, **kwargs): |
125 | 125 |
return views.login(request, *args, **kwargs) |
src/authentic2_auth_fc/views.py | ||
---|---|---|
147 | 147 |
display_name += family_name |
148 | 148 |
return display_name |
149 | 149 | |
150 |
def get(self, request, *args, **kwargs): |
|
150 |
def get(self, request, *args, next_url=None, **kwargs): |
|
151 |
if next_url: |
|
152 |
self._next_url = next_url |
|
153 | ||
151 | 154 |
self.authenticator = get_object_or_404(models.FcAuthenticator, enabled=True) |
152 | 155 | |
153 | 156 |
code = request.GET.get('code') |
src/authentic2_auth_oidc/models.py | ||
---|---|---|
232 | 232 |
def __repr__(self): |
233 | 233 |
return '<OIDCProvider %r>' % self.issuer |
234 | 234 | |
235 |
def autorun(self, request, *args): |
|
236 |
return redirect_to_login(request, login_url='oidc-login', kwargs={'pk': self.pk}) |
|
235 |
def autorun(self, request, block_id, next_url): |
|
236 |
return redirect_to_login( |
|
237 |
request, login_url='oidc-login', kwargs={'pk': self.pk}, params={'next': next_url} |
|
238 |
) |
|
237 | 239 | |
238 | 240 |
def login(self, request, *args, **kwargs): |
239 | 241 |
context = kwargs.get('context', {}).copy() |
src/authentic2_auth_saml/models.py | ||
---|---|---|
230 | 230 |
if not (self.metadata or self.metadata_url): |
231 | 231 |
raise ValidationError(_('One of the metadata fields must be filled.')) |
232 | 232 | |
233 |
def autorun(self, request, block_id): |
|
233 |
def autorun(self, request, block_id, next_url):
|
|
234 | 234 |
from .adapters import AuthenticAdapter |
235 | 235 | |
236 | 236 |
settings = self.settings |
237 | 237 |
AuthenticAdapter().load_idp(settings, self.order) |
238 | 238 |
return redirect_to_login( |
239 |
request, login_url='mellon_login', params={'entityID': settings['ENTITY_ID']} |
|
239 |
request, login_url='mellon_login', params={'entityID': settings['ENTITY_ID'], 'next': next_url}
|
|
240 | 240 |
) |
241 | 241 | |
242 | 242 |
def has_signing_key(self): |
tests/test_auth_oidc.py | ||
---|---|---|
492 | 492 |
slug='password-authenticator', defaults={'enabled': False} |
493 | 493 |
) |
494 | 494 |
response = app.get('/login/', status=302) |
495 |
assert response['Location'] == '/accounts/oidc/login/%s/' % oidc_provider.pk |
|
495 |
assert response['Location'] == '/accounts/oidc/login/%s/?next=/' % oidc_provider.pk
|
|
496 | 496 | |
497 | 497 | |
498 | 498 |
def test_sso(app, caplog, code, oidc_provider, oidc_provider_jwkset, hooks): |
499 |
- |