From 9aec43e4cfb0ad2ed08328a85deab6f56312038f Mon Sep 17 00:00:00 2001 From: Giuseppe De Marco Date: Mon, 16 Dec 2019 00:57:38 +0100 Subject: [PATCH] SLO exception workaround --- djangosaml2/views.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/djangosaml2/views.py b/djangosaml2/views.py index b328fff7..da89cc8f 100644 --- a/djangosaml2/views.py +++ b/djangosaml2/views.py @@ -36,6 +36,7 @@ from django.views.decorators.csrf import csrf_exempt from saml2 import BINDING_HTTP_REDIRECT, BINDING_HTTP_POST +from saml2.client_base import LogoutError from saml2.metadata import entity_descriptor from saml2.ident import code, decode from saml2.sigver import MissingKey @@ -376,7 +377,13 @@ def logout(request, config_loader_path=None): 'The session does not contain the subject id for user %s', request.user) - result = client.global_logout(subject_id) + try: + result = client.global_logout(subject_id) + except LogoutError as exp: + logger.exception('Error Handled - SLO not supported by IDP: {}'.format(exp)) + auth.logout(request) + state.sync() + return HttpResponseRedirect('/') state.sync()