Skip to content

Commit 00c59a9

Browse files
authored
Add an option to ignore logout errors (#227)
* Fix deprecated logging method * Add an option to ignore IDP logout errors
1 parent c72ecd1 commit 00c59a9

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ For example::
140140
import saml2
141141
SAML_LOGOUT_REQUEST_PREFERRED_BINDING = saml2.BINDING_HTTP_POST
142142

143+
Ignore Logout errors
144+
--------------------
145+
When logging out, a SAML IDP will return an error on invalid conditions, such as the IDP-side session being expired.
146+
Use the following setting to ignore these errors and perform a local Django logout nonetheless::
147+
148+
SAML_IGNORE_LOGOUT_ERRORS = True
149+
143150
Signed Logout Request
144151
------------------------
145152
Idp's like Okta require a signed logout response to validate and logout a user. Here's a sample config with all required SP/IDP settings::

djangosaml2/views.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ def do_logout_service(request, data, binding, config_loader_path=None, next_page
522522
response = client.parse_logout_request_response(data['SAMLResponse'], binding)
523523
except StatusError as e:
524524
response = None
525-
logger.warn("Error logging out from remote provider: " + str(e))
525+
logger.warning("Error logging out from remote provider: " + str(e))
526526
state.sync()
527527
return finish_logout(request, response, next_page=next_page)
528528

@@ -561,7 +561,9 @@ def do_logout_service(request, data, binding, config_loader_path=None, next_page
561561

562562

563563
def finish_logout(request, response, next_page=None):
564-
if response and response.status_ok():
564+
if (getattr(settings, 'SAML_IGNORE_LOGOUT_ERRORS', False) or
565+
(response and response.status_ok())):
566+
565567
if next_page is None and hasattr(settings, 'LOGOUT_REDIRECT_URL'):
566568
next_page = settings.LOGOUT_REDIRECT_URL
567569
logger.debug('Performing django logout with a next_page of %s',

0 commit comments

Comments
 (0)