Automated Action 8575427c43 Implement user authentication flow
- Setup project structure with FastAPI
- Create user models with SQLAlchemy
- Implement JWT authentication
- Create auth endpoints (register, login, me)
- Add health endpoint
- Generate Alembic migrations
- Update documentation

Generated with BackendIM... (backend.im)
2025-05-12 17:00:50 +00:00

44 lines
1.3 KiB
Python

import secrets
from typing import Any, Dict, List, Optional, Union
from pydantic import AnyHttpUrl, EmailStr, HttpUrl, validator
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
PROJECT_NAME: str = "User Authentication Flow Service"
DESCRIPTION: str = "A service for user authentication flow"
VERSION: str = "0.1.0"
API_V1_STR: str = "/api/v1"
# Secret key for JWT
SECRET_KEY: str = secrets.token_urlsafe(32)
# 60 minutes * 24 hours * 8 days = 8 days
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
# CORS settings
BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = []
@validator("BACKEND_CORS_ORIGINS", pre=True)
def assemble_cors_origins(cls, v: Union[str, List[str]]) -> Union[List[str], str]:
if isinstance(v, str) and not v.startswith("["):
return [i.strip() for i in v.split(",")]
elif isinstance(v, (list, str)):
return v
raise ValueError(v)
# Debug mode
DEBUG: bool = True
# Database settings
DB_PATH: str = "/app/storage/db/db.sqlite"
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_PATH}"
# First superuser
FIRST_SUPERUSER: EmailStr = "admin@example.com"
FIRST_SUPERUSER_PASSWORD: str = "admin"
class Config:
case_sensitive = True
settings = Settings()