diff options
author | Jonathan Huot <jonathan.huot@thomsonreuters.com> | 2019-03-26 14:50:41 +0100 |
---|---|---|
committer | Jonathan Huot <jonathan.huot@thomsonreuters.com> | 2019-03-26 14:50:41 +0100 |
commit | 53d3d335879f205ae705d93420f34984073cd5a1 (patch) | |
tree | 9748b3d22b422098eb18a1a2ab8ea3f11e3b7983 | |
parent | 55b152c89879e0165ffc97039bf963905c27812d (diff) | |
download | oauthlib-53d3d335879f205ae705d93420f34984073cd5a1.tar.gz |
Renamed fill into finalize to add clarity
-rw-r--r-- | docs/oauth2/oidc/id_tokens.rst | 6 | ||||
-rw-r--r-- | oauthlib/openid/connect/core/grant_types/base.py | 2 | ||||
-rw-r--r-- | oauthlib/openid/connect/core/request_validator.py | 8 | ||||
-rw-r--r-- | tests/openid/connect/core/test_request_validator.py | 4 |
4 files changed, 10 insertions, 10 deletions
diff --git a/docs/oauth2/oidc/id_tokens.rst b/docs/oauth2/oidc/id_tokens.rst index 2387c01..a1bf7cf 100644 --- a/docs/oauth2/oidc/id_tokens.rst +++ b/docs/oauth2/oidc/id_tokens.rst @@ -3,7 +3,7 @@ ID Tokens The creation of `ID Tokens`_ is ultimately not done by OAuthLib but by your ``RequestValidator`` subclass. This is because their content is dependent on your implementation of users, their attributes, any claims you may wish to support, as well as the -details of how you model the notion of a Client Application. As such OAuthLib simply calls your validator's ``fill_id_token`` +details of how you model the notion of a Client Application. As such OAuthLib simply calls your validator's ``finalize_id_token`` method at the appropriate times during the authorization flow, depending on the grant type requested (Authorization Code, Implicit, Hybrid, etc.). @@ -12,7 +12,7 @@ See examples below. .. _`ID Tokens`: http://openid.net/specs/openid-connect-core-1_0.html#IDToken .. autoclass:: oauthlib.oauth2.RequestValidator - :members: fill_id_token + :members: finalize_id_token JWT/JWS example with pyjwt library @@ -38,7 +38,7 @@ You can switch to jwcrypto library if you want to return JWE instead. super().__init__(self, **kwargs) - def fill_id_token(self, id_token, token, token_handler, request): + def finalize_id_token(self, id_token, token, token_handler, request): import jwt id_token["iss"] = "https://my.cool.app.com" diff --git a/oauthlib/openid/connect/core/grant_types/base.py b/oauthlib/openid/connect/core/grant_types/base.py index f925c64..31ff82e 100644 --- a/oauthlib/openid/connect/core/grant_types/base.py +++ b/oauthlib/openid/connect/core/grant_types/base.py @@ -145,7 +145,7 @@ class GrantTypeBase(object): id_token["c_hash"] = self.hash_id_token(token["code"]) # Call request_validator to complete/sign/encrypt id_token - token['id_token'] = self.request_validator.fill_id_token(id_token, token, token_handler, request) + token['id_token'] = self.request_validator.finalize_id_token(id_token, token, token_handler, request) return token diff --git a/oauthlib/openid/connect/core/request_validator.py b/oauthlib/openid/connect/core/request_validator.py index f8aeed8..7ce7e17 100644 --- a/oauthlib/openid/connect/core/request_validator.py +++ b/oauthlib/openid/connect/core/request_validator.py @@ -83,10 +83,10 @@ class RequestValidator(OAuth2RequestValidator): """Get OpenID Connect ID token This method is OPTIONAL and is NOT RECOMMENDED. - `fill_id_token` SHOULD be implemented instead. However, if you + `finalize_id_token` SHOULD be implemented instead. However, if you want a full control over the minting of the `id_token`, you MAY want to override `get_id_token` instead of using - `fill_id_token`. + `finalize_id_token`. In the OpenID Connect workflows when an ID Token is requested this method is called. Subclasses should implement the construction, signing and optional encryption of the @@ -118,8 +118,8 @@ class RequestValidator(OAuth2RequestValidator): """ return None - def fill_id_token(self, id_token, token, token_handler, request): - """Fill OpenID Connect ID token & Sign or Encrypt. + def finalize_id_token(self, id_token, token, token_handler, request): + """Finalize OpenID Connect ID token & Sign or Encrypt. In the OpenID Connect workflows when an ID Token is requested this method is called. Subclasses should implement the diff --git a/tests/openid/connect/core/test_request_validator.py b/tests/openid/connect/core/test_request_validator.py index e20e88f..ebe0aeb 100644 --- a/tests/openid/connect/core/test_request_validator.py +++ b/tests/openid/connect/core/test_request_validator.py @@ -22,8 +22,8 @@ class RequestValidatorTest(TestCase): ) self.assertRaises( NotImplementedError, - v.get_id_token, - 'token', 'token_handler', 'request' + v.finalize_id_token, + 'id_token', 'token', 'token_handler', 'request' ) self.assertRaises( NotImplementedError, |