Skip to content

Commit abfe310

Browse files
authored
Merge pull request #154 from peppelinux/SLO_absence_workaround
SLO absence workaround
2 parents b670a2b + 879bc36 commit abfe310

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

djangosaml2/views.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
from django.template import TemplateDoesNotExist
2929
from django.utils.http import is_safe_url
3030
from django.views.decorators.csrf import csrf_exempt
31-
from django.views.decorators.http import require_POST
32-
from saml2 import BINDING_HTTP_POST, BINDING_HTTP_REDIRECT
31+
from saml2 import BINDING_HTTP_REDIRECT, BINDING_HTTP_POST
32+
from saml2.client_base import LogoutError
33+
from saml2.metadata import entity_descriptor
3334
from saml2.ident import code, decode
3435
from saml2.metadata import entity_descriptor
3536
from saml2.response import (SignatureError, StatusAuthnFailed, StatusError,
@@ -376,7 +377,13 @@ def logout(request, config_loader_path=None):
376377
'The session does not contain the subject id for user %s',
377378
request.user)
378379

379-
result = client.global_logout(subject_id)
380+
try:
381+
result = client.global_logout(subject_id)
382+
except LogoutError as exp:
383+
logger.exception('Error Handled - SLO not supported by IDP: {}'.format(exp))
384+
auth.logout(request)
385+
state.sync()
386+
return HttpResponseRedirect('/')
380387

381388
state.sync()
382389

0 commit comments

Comments
 (0)