Skip to content
Snippets Groups Projects
Commit 12b7ff5c71cf authored by Houzefa Abbasbhay's avatar Houzefa Abbasbhay :slight_smile:
Browse files

Don't add different states twice to the same URL

parent 8b042b14ecfe
No related branches found
No related tags found
No related merge requests found
...@@ -97,6 +97,12 @@ ...@@ -97,6 +97,12 @@
class AuthSAMLController(http.Controller): class AuthSAMLController(http.Controller):
def get_state(self, provider_id): def get_state(self, provider_id):
"""Compute a state to be sent to the IDP so it can forward it back to
us.
:rtype: Dictionary.
"""
redirect = request.params.get('redirect') or 'web' redirect = request.params.get('redirect') or 'web'
if not redirect.startswith(('//', 'http://', 'https://')): if not redirect.startswith(('//', 'http://', 'https://')):
redirect = '%s%s' % ( redirect = '%s%s' % (
...@@ -121,6 +127,9 @@ ...@@ -121,6 +127,9 @@
provider_osv = request.registry.get('auth.saml.provider') provider_osv = request.registry.get('auth.saml.provider')
auth_request = None auth_request = None
# store a RelayState on the request to our IDP so that the IDP
# can send us back this info alongside the obtained token
state = self.get_state(provider_id) state = self.get_state(provider_id)
try: try:
...@@ -133,16 +142,7 @@ ...@@ -133,16 +142,7 @@
# TODO: handle case when auth_request comes back as None # TODO: handle case when auth_request comes back as None
# store a RelayState on the request to our IDP so that the IDP redirect = werkzeug.utils.redirect(auth_request, 303)
# can send us back this info alongside the obtained token
params = {
"RelayState": simplejson.dumps({
"d": request.session.db,
"p": pid,
}),
}
url = auth_request + "&" + werkzeug.url_encode(params)
redirect = werkzeug.utils.redirect(url, 303)
redirect.autocorrect_location_header = True redirect.autocorrect_location_header = True
return redirect return redirect
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment