summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2019-03-20 12:55:00 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2019-03-20 13:28:05 (GMT)
commitca6ce92781f52efdb463398f0ad202e539d7e2b4 (patch)
tree8abfc2589303300d13c83983543e9f03c7eba603
parentd0e6f46f9bcb25df68a99d8ed375f9454a9ffb73 (diff)
downloaddjango-mellon-ca6ce92781f52efdb463398f0ad202e539d7e2b4.zip
django-mellon-ca6ce92781f52efdb463398f0ad202e539d7e2b4.tar.gz
django-mellon-ca6ce92781f52efdb463398f0ad202e539d7e2b4.tar.bz2
views: fix discovery URL building (#31581)v1.2.40
-rw-r--r--mellon/views.py6
-rw-r--r--tests/test_views.py2
2 files changed, 5 insertions, 3 deletions
diff --git a/mellon/views.py b/mellon/views.py
index babf813..889d40b 100644
--- a/mellon/views.py
+++ b/mellon/views.py
@@ -348,12 +348,14 @@ class LoginView(ProfileMixin, LogMixin, View):
return self.sso_failure(request, login, reason=idp_message, status_codes=status_codes)
def request_discovery_service(self, request, is_passive=False):
- self_url = request.build_absolute_uri() + '&nodisco=1'
+ return_url = request.build_absolute_uri()
+ return_url += '&' if '?' in return_url else '?'
+ return_url += 'nodisco=1'
url = app_settings.DISCOVERY_SERVICE_URL
params = {
# prevent redirect loops with the discovery service
'entityID': request.build_absolute_uri(reverse('mellon_metadata')),
- 'return': self_url,
+ 'return': return_url,
}
if is_passive:
params['isPassive'] = 'true'
diff --git a/tests/test_views.py b/tests/test_views.py
index 9292de7..014af86 100644
--- a/tests/test_views.py
+++ b/tests/test_views.py
@@ -147,7 +147,7 @@ def test_sp_initiated_login_discovery_service_passive(private_settings, client):
assert response['Location'].startswith('https://disco?')
assert params == {'isPassive': ['true'],
'entityID': ['http://testserver/metadata/'],
- 'return': ['http://testserver/login/?nodisco=1']}
+ 'return': ['http://testserver/login/?passive=1&nodisco=1']}
def test_sp_initiated_login_discovery_service_nodisco(private_settings, client):