Projet

Général

Profil

0001-middleware-disable-automatic-passive-authentication-.patch

Benjamin Dauvergne, 27 juillet 2021 11:49

Télécharger (2,35 ko)

Voir les différences:

Subject: [PATCH] middleware: disable automatic passive authentication if
 ?noauth (#55854)

You can add ?noauth to an URL do disable passive authentication based on
an IdP set common domain cookie.
 mellon/middleware.py  |  3 +++
 tests/test_sso_slo.py | 10 +++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)
mellon/middleware.py
37 37
        return response
38 38

  
39 39
    def process_view(self, request, view_func, view_args, view_kwargs):
40
        # skip if explicitely asked in the query string
41
        if 'no-passive-auth' in request.GET:
42
            return
40 43
        # Skip AJAX requests
41 44
        if request.is_ajax():
42 45
            return
tests/test_sso_slo.py
656 656
        assert login_hints[0].text == 'backoffice', 'login hint is not backoffice'
657 657

  
658 658

  
659
def test_middleware_mixin_first_time(db, app, idp, caplog, settings):
659
def test_passive_auth_middleware_ok(db, app, idp, caplog, settings):
660 660
    settings.MELLON_OPENED_SESSION_COOKIE_NAME = 'IDP_SESSION'
661 661
    assert 'MELLON_PASSIVE_TRIED' not in app.cookies
662 662
    # webtest-lint is against unicode
......
688 688
    assert 'MELLON_PASSIVE_TRIED' in app.cookies
689 689

  
690 690

  
691
def test_passive_auth_middleware_no_passive_auth_parameter(db, app, idp, caplog, settings):
692
    settings.MELLON_OPENED_SESSION_COOKIE_NAME = 'IDP_SESSION'
693
    assert 'MELLON_PASSIVE_TRIED' not in app.cookies
694
    # webtest-lint is against unicode
695
    app.set_cookie(str('IDP_SESSION'), str('1'))
696
    app.get('/?no-passive-auth', headers={'Accept': force_str('text/html')}, status=200)
697

  
698

  
691 699
def test_sso_user_change(db, app, idp, caplog, sp_settings):
692 700
    response = app.get(reverse('mellon_login') + '?next=/whatever/')
693 701
    url, body, relay_state = idp.process_authn_request_redirect(response['Location'])
694
-