forked from feast-dev/feast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoken_parser.py
More file actions
28 lines (20 loc) · 765 Bytes
/
token_parser.py
File metadata and controls
28 lines (20 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from abc import ABC, abstractmethod
from feast.permissions.user import User
class TokenParser(ABC):
"""
A class to parse an access token to extract the user credential and roles.
"""
@abstractmethod
async def user_details_from_access_token(self, access_token: str) -> User:
"""
Parse the access token and return the current user and the list of associated roles.
Returns:
User: Current user, with associated roles.
"""
raise NotImplementedError()
class NoAuthTokenParser(TokenParser):
"""
A `TokenParser` always returning an empty token
"""
async def user_details_from_access_token(self, access_token: str, **kwargs) -> User:
return User(username="", roles=[])