summaryrefslogtreecommitdiff
path: root/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py
diff options
context:
space:
mode:
authorJoel Stevenson <jstevenson@bepress.com>2016-05-06 14:52:49 -0700
committerJoel Stevenson <jstevenson@bepress.com>2016-05-06 14:52:49 -0700
commit9a8f73d2dd088d5ea01313de2a1fe5a877994a79 (patch)
tree583587f2d4f8b2fbdfc4ae9fd3bb0bd47a0c4901 /oauthlib/oauth2/rfc6749/grant_types/authorization_code.py
parent1a186cec18a503ee2f26026138a5614fb582e46f (diff)
downloadoauthlib-9a8f73d2dd088d5ea01313de2a1fe5a877994a79.tar.gz
Reworking the handling of claims. @bjmc was quite right to question the haste-y inclusion in the Resource endpoint. It is an optional parameter to the Authorization Code endpoint and so needs to be stored with both the generated authorization code grant and any subsequent access token issued to that authorization code.
Diffstat (limited to 'oauthlib/oauth2/rfc6749/grant_types/authorization_code.py')
-rw-r--r--oauthlib/oauth2/rfc6749/grant_types/authorization_code.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py b/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py
index 91d7615..3a77fd9 100644
--- a/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py
+++ b/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py
@@ -367,12 +367,25 @@ class AuthorizationCodeGrant(GrantTypeBase):
# http://tools.ietf.org/html/rfc6749#section-3.3
self.validate_scopes(request)
+ # validate_authorization_request may be called multiple times in a single request
+ # so make sure we only de-serialize the claims once
+ if request.claims and not isinstance(request.claims, dict) and request.scopes and "openid" in request.scopes:
+ # specific claims are requested during the Authorization Request and may be requested for inclusion
+ # in either the id_token or the UserInfo endpoint response
+ # see http://openid.net/specs/openid-connect-core-1_0.html#ClaimsParameter
+ try:
+ request.claims = json.loads(request.claims)
+ except Exception as ex:
+ raise errors.InvalidRequestError(description="Malformed claims parameter",
+ uri="http://openid.net/specs/openid-connect-core-1_0.html#ClaimsParameter")
+
request_info = {
'client_id': request.client_id,
'redirect_uri': request.redirect_uri,
'response_type': request.response_type,
'state': request.state,
'request': request,
+ 'claims': request.claims
}
for validator in self._authorization_validators: