Skip to content

Add an option to ignore logout errors #227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ For example::
import saml2
SAML_LOGOUT_REQUEST_PREFERRED_BINDING = saml2.BINDING_HTTP_POST

Ignore Logout errors
--------------------
When logging out, a SAML IDP will return an error on invalid conditions, such as the IDP-side session being expired.
Use the following setting to ignore these errors and perform a local Django logout nonetheless::

SAML_IGNORE_LOGOUT_ERRORS = True

Signed Logout Request
------------------------
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::
Expand Down
6 changes: 4 additions & 2 deletions djangosaml2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def do_logout_service(request, data, binding, config_loader_path=None, next_page
response = client.parse_logout_request_response(data['SAMLResponse'], binding)
except StatusError as e:
response = None
logger.warn("Error logging out from remote provider: " + str(e))
logger.warning("Error logging out from remote provider: " + str(e))
state.sync()
return finish_logout(request, response, next_page=next_page)

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


def finish_logout(request, response, next_page=None):
if response and response.status_ok():
if (getattr(settings, 'SAML_IGNORE_LOGOUT_ERRORS', False) or
(response and response.status_ok())):

if next_page is None and hasattr(settings, 'LOGOUT_REDIRECT_URL'):
next_page = settings.LOGOUT_REDIRECT_URL
logger.debug('Performing django logout with a next_page of %s',
Expand Down