Skip to content

Commit d0776e9

Browse files
committed
Update token auth handling to use HanaToken model instead of encoded string
1 parent 7987ce6 commit d0776e9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

neon_users_service/service.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from copy import copy
55
from typing import Optional
66
from ovos_config import Configuration
7+
8+
from neon_data_models.models.api.jwt import HanaToken
79
from neon_users_service.databases import UserDatabase
810
from neon_users_service.exceptions import (ConfigurationError,
911
AuthenticationError,
@@ -58,11 +60,11 @@ def create_user(self, user: User) -> User:
5860
return self.database.create_user(user)
5961

6062
def _read_user(self, user_spec: str, password: Optional[str] = None,
61-
auth_token: Optional[str] = None) -> User:
63+
auth_token: Optional[HanaToken] = None) -> User:
6264
user = self.database.read_user(user_spec)
6365
if password and self._ensure_hashed(password) == user.password_hash:
6466
return user
65-
elif auth_token and any((tok.access_token == auth_token
67+
elif auth_token and any((tok.jti == f"{auth_token.jti}.refresh"
6668
for tok in user.tokens)):
6769
return user
6870
else:
@@ -82,7 +84,7 @@ def read_unauthenticated_user(self, user_spec: str) -> User:
8284

8385
def read_authenticated_user(self, username: str,
8486
password: Optional[str] = None,
85-
auth_token: Optional[str] = None) -> User:
87+
auth_token: Optional[HanaToken] = None) -> User:
8688
"""
8789
Helper to get a user from the database, only if the requested username
8890
and password match a database entry.

0 commit comments

Comments
 (0)