Skip to content

Commit 51a59e1

Browse files
Merge pull request #114 from jkakavas/fix_error_handling
Correctly handle error responses
2 parents e5868d7 + 8092230 commit 51a59e1

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)