Skip to content

Commit 8092230

Browse files
author
Ioannis Kakavas
committed
Correctly handle error responses
In case of an error, reflect the state to the client in the error response (if the client sent a state parameter in the original request)
1 parent e5868d7 commit 8092230

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/satosa/frontends/openid_connect.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,14 @@ def handle_backend_error(self, exception):
129129
:rtype: oic.utils.http_util.Response
130130
"""
131131
auth_req = self._get_authn_request_from_state(exception.state)
132-
error_resp = AuthorizationErrorResponse(error="access_denied", error_description=exception.message)
132+
# If the client sent us a state parameter, we should reflect it back according to the spec
133+
if 'state' in auth_req:
134+
error_resp = AuthorizationErrorResponse(error="access_denied",
135+
error_description=exception.message,
136+
state=auth_req['state'])
137+
else:
138+
error_resp = AuthorizationErrorResponse(error="access_denied",
139+
error_description=exception.message)
133140
satosa_logging(logger, logging.DEBUG, exception.message, exception.state)
134141
return SeeOther(error_resp.request(auth_req["redirect_uri"], should_fragment_encode(auth_req)))
135142

0 commit comments

Comments
 (0)