Spaces:
Sleeping
Sleeping
Download adsp/app/auth_service.py from thanhnv2323/humanize-text-python: direct link, hf CLI and curl.
- Browser
- Download file 816 Bytes
-
https://huggingface.co/spaces/thanhnv2323/humanize-text-python/resolve/main/adsp/app/auth_service.py
- Command line
-
hf download hf://spaces/thanhnv2323/humanize-text-python/adsp/app/auth_service.py
-
curl -L -o auth_service.py https://huggingface.co/spaces/thanhnv2323/humanize-text-python/resolve/main/adsp/app/auth_service.py
816 Bytes
| """Authentication and authorization helpers for UI clients.""" | |
| from __future__ import annotations | |
| from dataclasses import dataclass, field | |
| from typing import Dict | |
| class AuthService: | |
| """Very small in-memory auth registry for illustration purposes. | |
| It has to manage authentication and authorization, user access, permissions, and ensure only authorized users can interact | |
| with certain parts of the system""" | |
| _tokens: Dict[str, str] = field(default_factory=dict) | |
| def register(self, user: str, token: str) -> None: | |
| """Register a token for a given user.""" | |
| self._tokens[user] = token | |
| def is_authorized(self, user: str, token: str) -> bool: | |
| """Validate whether the provided token matches the stored one.""" | |
| return self._tokens.get(user) == token | |