Automated Action 5b55eedd2b Implement User Authentication and Authorization Service
This commit includes:
- User registration and authentication API with JWT
- Password reset functionality
- Role-based access control system
- Database models and migrations with SQLAlchemy and Alembic
- API documentation in README

generated with BackendIM... (backend.im)
2025-05-15 19:46:38 +00:00

45 lines
1.3 KiB
Python

import os
from pathlib import Path
from typing import List, Optional
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
# API settings
API_V1_STR: str = "/api/v1"
PROJECT_NAME: str = "User Authentication and Authorization Service"
# JWT settings
SECRET_KEY: str = os.getenv("SECRET_KEY", "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7")
ALGORITHM: str = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
REFRESH_TOKEN_EXPIRE_MINUTES: int = 10080 # 7 days
# CORS settings
BACKEND_CORS_ORIGINS: List[str] = ["*"]
# Database settings
DB_DIR: Path = Path("/app") / "storage" / "db"
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
# Password reset settings
PASSWORD_RESET_TOKEN_EXPIRE_HOURS: int = 24
# Email settings (if you plan to implement email sending)
SMTP_TLS: bool = True
SMTP_PORT: Optional[int] = None
SMTP_HOST: Optional[str] = None
SMTP_USER: Optional[str] = None
SMTP_PASSWORD: Optional[str] = None
EMAILS_FROM_EMAIL: Optional[str] = None
EMAILS_FROM_NAME: Optional[str] = None
class Config:
env_file = ".env"
case_sensitive = True
# Create the settings object
settings = Settings()
# Ensure the database directory exists
settings.DB_DIR.mkdir(parents=True, exist_ok=True)