From a295d21a42a6ae9c463f7661b32df7de11095835 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Mon, 11 Mar 2024 21:05:57 +0300 Subject: 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 --- gn_auth/auth/authentication/oauth2/endpoints/introspection.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gn_auth/auth/authentication/oauth2/endpoints') 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, -- cgit v1.2.3