From 94b1f5b04bcee2ded0d0cbf11df4101bb86d6ce8 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 31 Jan 2023 04:45:53 +0300 Subject: auth: Set the token scope as a string, not a list Setting the scope as a list of strings was leading to errors when attempting to logout. This commit leaves the scope as a string to avoid the errors. --- gn3/auth/authentication/oauth2/models/oauth2token.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gn3/auth/authentication/oauth2') diff --git a/gn3/auth/authentication/oauth2/models/oauth2token.py b/gn3/auth/authentication/oauth2/models/oauth2token.py index 9495df4..c1fcafb 100644 --- a/gn3/auth/authentication/oauth2/models/oauth2token.py +++ b/gn3/auth/authentication/oauth2/models/oauth2token.py @@ -1,7 +1,7 @@ """OAuth2 Token""" import uuid import datetime -from typing import NamedTuple, Optional, Sequence +from typing import NamedTuple, Optional from pymonad.maybe import Just, Maybe, Nothing @@ -17,7 +17,7 @@ class OAuth2Token(NamedTuple): token_type: str access_token: str refresh_token: Optional[str] - scope: Sequence[str] + scope: str revoked: bool issued_at: datetime.datetime expires_in: int @@ -38,7 +38,7 @@ class OAuth2Token(NamedTuple): def get_scope(self) -> str: """Return the valid scope for the token.""" - return " ".join(self.scope) + return self.scope def is_expired(self) -> bool: """Check whether the token is expired.""" @@ -60,7 +60,7 @@ def __token_from_resultset__(conn: db.DbConnection, rset) -> Maybe: token_type=rset["token_type"], access_token=rset["access_token"], refresh_token=rset["refresh_token"], - scope=rset["scope"].split(None), + scope=rset["scope"], revoked=(rset["revoked"] == 1), issued_at=datetime.datetime.fromtimestamp( rset["issued_at"]), -- cgit v1.2.3