From 945fb8504ef3e15849a5b3e2bec08cf252ae2feb Mon Sep 17 00:00:00 2001 From: Giuseppe De Marco Date: Mon, 15 Feb 2021 23:38:33 +0100 Subject: [PATCH] v1.0.3 (#244) * Wayf page with fallback value if any display name for idps * v1.0.3 --- CHANGES | 4 ++++ djangosaml2/templates/djangosaml2/wayf.html | 2 +- djangosaml2/views.py | 11 +++++++---- setup.py | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index 5fd7834e..77b3c334 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ Changes ======= +v1.0.3 (2020-02-04) +- Django Logout behaviour improved + + v1.0.2 (2020-01-24) - RequestVersionTooLow exception handled in ACS - Better exception handling for Malformed SAML Response diff --git a/djangosaml2/templates/djangosaml2/wayf.html b/djangosaml2/templates/djangosaml2/wayf.html index 179416ec..71687046 100644 --- a/djangosaml2/templates/djangosaml2/wayf.html +++ b/djangosaml2/templates/djangosaml2/wayf.html @@ -9,7 +9,7 @@

Where are you from?

Please select your Identity Provider from the following list:

diff --git a/djangosaml2/views.py b/djangosaml2/views.py index ad47eeaf..0c4ba569 100644 --- a/djangosaml2/views.py +++ b/djangosaml2/views.py @@ -82,7 +82,10 @@ def get_sp_config(self, request: HttpRequest) -> SPConfig: def get_state_client(self, request: HttpRequest): conf = self.get_sp_config(request) state = StateCache(request.saml_session) - client = Saml2Client(conf, state_cache=state, identity_cache=IdentityCache(request.saml_session)) + client = Saml2Client( + conf, state_cache=state, + identity_cache=IdentityCache(request.saml_session) + ) return state, client @@ -466,7 +469,7 @@ def get(self, request, *args, **kwargs): logger.exception('Error Handled - SLO not supported by IDP: {}'.format(exp)) auth.logout(request) state.sync() - return HttpResponseRedirect(settings.LOGOUT_REDIRECT_URL) + return HttpResponseRedirect(getattr(settings, 'LOGOUT_REDIRECT_URL', '/')) auth.logout(request) state.sync() @@ -567,8 +570,8 @@ def do_logout_service(self, request, data, binding): def finish_logout(request, response, next_page=None): 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 + if not next_page: + next_page = getattr(settings, 'LOGOUT_REDIRECT_URL', '/') logger.debug('Performing django logout with a next_page of %s', next_page) return AuthLogoutView.as_view()(request, next_page=next_page) logger.error('Unknown error during the logout') diff --git a/setup.py b/setup.py index f30a920b..dc186942 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ def read(*rnames): setup( name='djangosaml2', - version='1.0.2', + version='1.0.3', description='pysaml2 integration for Django', long_description=read('README.rst'), classifiers=[