diff options
author | Munyoki Kilyungi | 2024-03-11 21:05:57 +0300 |
---|---|---|
committer | Munyoki Kilyungi | 2024-03-13 10:25:11 +0300 |
commit | a295d21a42a6ae9c463f7661b32df7de11095835 (patch) | |
tree | cc5bfe988912113b4659e60c5f34ff0fa54024e0 /gn_auth/auth/authentication/oauth2/endpoints | |
parent | 27d40788e2e2c8fbeb8873e895d77a76bbd49a45 (diff) | |
download | gn-auth-a295d21a42a6ae9c463f7661b32df7de11095835.tar.gz |
Define OAuth2Token using a frozen dataclass.
* gn_auth/auth/authentication/oauth2/endpoints/introspection.py
(IntrospectionEndpoint.introspect_token): Replace token.get_scope()
with token.scope.
* gn_auth/auth/authentication/oauth2/models/oauth2token.py: Import
dataclass, TokenMixin and cached_property. Delete NamedTuple import.
(OAuth2Token): Use a frozen dataclass and explicitly inherit from
TokenMixin.
(OAuth2Token.expires_at): Make this a cached_property.
(OAuth2Token.check_client): Add the "# pylint ..." in it's own line.
Tested-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn_auth/auth/authentication/oauth2/endpoints')
-rw-r--r-- | gn_auth/auth/authentication/oauth2/endpoints/introspection.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gn_auth/auth/authentication/oauth2/endpoints/introspection.py b/gn_auth/auth/authentication/oauth2/endpoints/introspection.py index 222ddcb..572324e 100644 --- a/gn_auth/auth/authentication/oauth2/endpoints/introspection.py +++ b/gn_auth/auth/authentication/oauth2/endpoints/introspection.py @@ -24,12 +24,13 @@ class IntrospectionEndpoint(_IntrospectionEndpoint): """Query the token.""" return _query_token(self, token_string, token_type_hint) - def introspect_token(self, token: OAuth2Token) -> dict:# pylint: disable=[no-self-use] + # pylint: disable=[no-self-use] + def introspect_token(self, token: OAuth2Token) -> dict: """Return the introspection information.""" url = urlparse(flask_request.url) return { "active": True, - "scope": token.get_scope(), + "scope": token.scope, "client_id": token.client.client_id, "username": token.user.name, "token_type": token.token_type, |