Skip to content

Commit

Permalink
Merge pull request #463 from skion/fragment-errors
Browse files Browse the repository at this point in the history
Redirect errors according to OIDC's response_mode.
  • Loading branch information
thedrow committed Mar 31, 2017
2 parents e6c6ddb + 739c673 commit e8d8e0a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion oauthlib/oauth2/rfc6749/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ def __init__(self, description=None, uri=None, state=None, status_code=None,
self.client_id = request.client_id
self.scopes = request.scopes
self.response_type = request.response_type
self.response_mode = request.response_mode
self.grant_type = request.grant_type
if not state:
self.state = request.state

def in_uri(self, uri):
return add_params_to_uri(uri, self.twotuples)
return add_params_to_uri(uri, self.twotuples,
fragment=self.response_mode == "fragment")

@property
def twotuples(self):
Expand Down
5 changes: 4 additions & 1 deletion oauthlib/oauth2/rfc6749/grant_types/authorization_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@ def create_authorization_response(self, request, token_handler):
except errors.OAuth2Error as e:
log.debug('Client error during validation of %r. %r.', request, e)
request.redirect_uri = request.redirect_uri or self.error_uri
return {'Location': common.add_params_to_uri(request.redirect_uri, e.twotuples)}, None, 302
redirect_uri = common.add_params_to_uri(
request.redirect_uri, e.twotuples,
fragment=request.response_mode == "fragment")
return {'Location': redirect_uri}, None, 302

grant = self.create_authorization_code(request)
for modifier in self._code_modifiers:
Expand Down

0 comments on commit e8d8e0a

Please sign in to comment.