diff options
Diffstat (limited to 'oauthlib/oauth2/rfc6749')
4 files changed, 6 insertions, 14 deletions
diff --git a/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py b/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py index d35b55a..a47d01a 100644 --- a/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py +++ b/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py @@ -122,8 +122,6 @@ class AuthorizationCodeGrant(GrantTypeBase): def register_token_modifier(self, modifier): self._token_modifiers.append(modifier) - # END-NEW-FOR-OPENID - def create_authorization_code(self, request): """Generates an authorization grant represented as a dictionary.""" grant = {'code': common.generate_token()} diff --git a/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py b/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py index df5788c..1d9d2df 100644 --- a/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py +++ b/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py @@ -52,12 +52,10 @@ class ClientCredentialsGrant(GrantTypeBase): def __init__(self, request_validator=None): self.request_validator = request_validator or RequestValidator() - # NEW-FOR-OPENID self._token_modifiers = [] def register_token_modifier(self, modifier): self._token_modifiers.append(modifier) - # END-NEW-FOR-OPENID def create_token_response(self, request, token_handler): """Return token or error in JSON format. @@ -84,11 +82,11 @@ class ClientCredentialsGrant(GrantTypeBase): return headers, e.json, e.status_code token = token_handler.create_token(request, refresh_token=False) - # NEW-FOR-OPENID + for modifier in self._token_modifiers: token = modifier(token) self.request_validator.save_token(token, request) - # END-NEW-FOR-OPENID + log.debug('Issuing token to client id %r (%r), %r.', request.client_id, request.client, token) return headers, json.dumps(token), 200 diff --git a/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py b/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py index 864ef06..209b8a2 100644 --- a/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py +++ b/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py @@ -25,12 +25,10 @@ class RefreshTokenGrant(GrantTypeBase): def __init__(self, request_validator=None, issue_new_refresh_tokens=True): self.request_validator = request_validator or RequestValidator() self.issue_new_refresh_tokens = issue_new_refresh_tokens - # NEW-OPENID self._token_modifiers = [] def register_token_modifier(self, modifier): self._token_modifiers.append(modifier) - # END-NEW-OPENID def create_token_response(self, request, token_handler): """Create a new access token from a refresh_token. @@ -64,11 +62,11 @@ class RefreshTokenGrant(GrantTypeBase): token = token_handler.create_token(request, refresh_token=self.issue_new_refresh_tokens) - # NEW-OPENID + for modifier in self._token_modifiers: token = modifier(token) self.request_validator.save_token(token, request) - # END-NEW-OPENID + log.debug('Issuing new token to client id %r (%r), %r.', request.client_id, request.client, token) return headers, json.dumps(token), 200 diff --git a/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py b/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py index bf932cf..16690ae 100644 --- a/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py +++ b/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py @@ -77,12 +77,10 @@ class ResourceOwnerPasswordCredentialsGrant(GrantTypeBase): """ self.request_validator = request_validator or RequestValidator() self.refresh_token = refresh_token - # NEW-FOR-OPENID self._token_modifiers = [] def register_token_modifier(self, modifier): self._token_modifiers.append(modifier) - # END-NEW-FOR-OPENID def create_token_response(self, request, token_handler): """Return token or error in json format. @@ -117,11 +115,11 @@ class ResourceOwnerPasswordCredentialsGrant(GrantTypeBase): return headers, e.json, e.status_code token = token_handler.create_token(request, self.refresh_token) - # NEW-FOR-OPENID + for modifier in self._token_modifiers: token = modifier(token) self.request_validator.save_token(token, request) - # END-NEW-FOR-OPENID + log.debug('Issuing token %r to client id %r (%r) and username %s.', token, request.client_id, request.client, request.username) return headers, json.dumps(token), 200 |