Spaces:
Sleeping
Sleeping
Download classes.py from Arcader7171/InterState: direct link, hf CLI and curl.
- Browser
- Download file 690 Bytes
-
https://huggingface.co/spaces/Arcader7171/InterState/resolve/main/classes.py
- Command line
-
hf download hf://spaces/Arcader7171/InterState/classes.py
-
curl -L -o classes.py https://huggingface.co/spaces/Arcader7171/InterState/resolve/main/classes.py
690 Bytes
| import os | |
| import jwt | |
| from jwt.exceptions import InvalidTokenError as jwtITError, DecodeError as jwtDError, InvalidSignatureError as jwtISError | |
| import supabase | |
| jwtKey: string = os.environ.get("JWTKey") | |
| class User: | |
| def __init__(self, username, token): | |
| self.name = username | |
| self.token = token # Tokens should be JWT | |
| def validate(self): | |
| try: | |
| curToken = jwt.decode(self.token, jwtKey, algorithms="HS256") | |
| except jwtDError: | |
| return (false, "Validation failed") | |
| try: | |
| if curToken["username"] != self.name: | |
| raise jwtDError | |
| else: | |
| return (true, "OK") | |