diff options
author | Jonathan Huot <JonathanHuot@users.noreply.github.com> | 2019-07-09 17:14:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-09 17:14:49 +0200 |
commit | 3de7007c6885f0ac23ff2c56d6a65d8f258600a2 (patch) | |
tree | 78215926dc598674ee44eea3c03c0e6e0ca81034 /oauthlib/openid/connect/core/grant_types/authorization_code.py | |
parent | 75cc688ed923724e1bfe20a2a030ee92a151095e (diff) | |
parent | d7b90fc841694f126ec63500ea8f74330c4672eb (diff) | |
download | oauthlib-3de7007c6885f0ac23ff2c56d6a65d8f258600a2.tar.gz |
Merge branch 'master' into docs-flows-hooks
Diffstat (limited to 'oauthlib/openid/connect/core/grant_types/authorization_code.py')
-rw-r--r-- | oauthlib/openid/connect/core/grant_types/authorization_code.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/oauthlib/openid/connect/core/grant_types/authorization_code.py b/oauthlib/openid/connect/core/grant_types/authorization_code.py index b0b1015..becfcfa 100644 --- a/oauthlib/openid/connect/core/grant_types/authorization_code.py +++ b/oauthlib/openid/connect/core/grant_types/authorization_code.py @@ -22,3 +22,23 @@ class AuthorizationCodeGrant(GrantTypeBase): self.custom_validators.post_auth.append( self.openid_authorization_validator) self.register_token_modifier(self.add_id_token) + + def add_id_token(self, token, token_handler, request): + """ + Construct an initial version of id_token, and let the + request_validator sign or encrypt it. + + The authorization_code version of this method is used to + retrieve the nonce accordingly to the code storage. + """ + # Treat it as normal OAuth 2 auth code request if openid is not present + if not request.scopes or 'openid' not in request.scopes: + return token + + nonce = self.request_validator.get_authorization_code_nonce( + request.client_id, + request.code, + request.redirect_uri, + request + ) + return super(AuthorizationCodeGrant, self).add_id_token(token, token_handler, request, nonce=nonce) |