Spaces:
Runtime error
Runtime error
Download app/models/api_key.py from simhaa-hat/ai-learning-dashboard: direct link, hf CLI and curl.
- Browser
- Download file 826 Bytes
-
https://huggingface.co/spaces/simhaa-hat/ai-learning-dashboard/resolve/main/app/models/api_key.py
- Command line
-
hf download hf://spaces/simhaa-hat/ai-learning-dashboard/app/models/api_key.py
-
curl -L -o api_key.py https://huggingface.co/spaces/simhaa-hat/ai-learning-dashboard/resolve/main/app/models/api_key.py
826 Bytes
| """API Key document — persisted token credentials per user.""" | |
| from beanie import PydanticObjectId | |
| from pydantic import Field | |
| from app.models.base import BaseDocument | |
| class ApiKey(BaseDocument): | |
| """Hashed API key scoped to a user with a role label.""" | |
| user_id: PydanticObjectId | |
| name: str = Field(description="Human-readable label for this key") | |
| key_prefix: str = Field(description="First 8 chars of the raw key (display only)") | |
| key_hash: str = Field(description="SHA-256 hash of the raw key for verification") | |
| role: str = Field(default="Engineer", description="Role label: Admin | Engineer | Viewer") | |
| class Settings: | |
| name = "api_keys" | |
| use_state_management = True | |
| indexes = [ | |
| "user_id", | |
| [("created_at", -1)], | |
| ] | |