Automated Action d63fc9b68d Implement complete Enviodeck Authentication API with FastAPI
- Phone number authentication with OTP verification
- Email/password authentication with secure bcrypt hashing
- Third-party OAuth login support for Google and Apple
- JWT token-based authentication system
- Rate limiting for OTP requests (5/minute)
- SQLite database with SQLAlchemy ORM
- Comprehensive user model with multiple auth providers
- Alembic database migrations setup
- API documentation with Swagger/OpenAPI
- Health check and system endpoints
- Environment configuration with security best practices
- Code quality with Ruff linting and formatting

Features:
- POST /auth/request-otp - Request OTP for phone authentication
- POST /auth/verify-otp - Verify OTP and get access token
- POST /auth/signup-email - Email signup with password
- POST /auth/login-email - Email login authentication
- POST /auth/login-google - Google OAuth integration
- POST /auth/login-apple - Apple OAuth integration
- GET /user/me - Get current authenticated user info
- GET / - API information and documentation links
- GET /health - Application health check
2025-06-21 08:59:35 +00:00

45 lines
1.4 KiB
Python

from pathlib import Path
from decouple import config
class Settings:
PROJECT_NAME: str = "Enviodeck Authentication API"
PROJECT_VERSION: str = "1.0.0"
# Database
DB_DIR = Path("/app") / "storage" / "db"
DB_DIR.mkdir(parents=True, exist_ok=True)
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"
# JWT
JWT_SECRET_KEY: str = config(
"JWT_SECRET_KEY", default="your-secret-key-change-this"
)
JWT_ALGORITHM: str = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30 * 24 * 60 # 30 days
# Redis (for OTP storage)
REDIS_URL: str = config("REDIS_URL", default="redis://localhost:6379")
# OTP settings
OTP_EXPIRE_MINUTES: int = 5
OTP_MAX_ATTEMPTS: int = 3
# Rate limiting
RATE_LIMIT_REQUESTS: int = 5
RATE_LIMIT_WINDOW: int = 60 # seconds
# Third-party auth
GOOGLE_CLIENT_ID: str = config("GOOGLE_CLIENT_ID", default="")
GOOGLE_CLIENT_SECRET: str = config("GOOGLE_CLIENT_SECRET", default="")
APPLE_CLIENT_ID: str = config("APPLE_CLIENT_ID", default="")
APPLE_CLIENT_SECRET: str = config("APPLE_CLIENT_SECRET", default="")
# Twilio (for SMS)
TWILIO_ACCOUNT_SID: str = config("TWILIO_ACCOUNT_SID", default="")
TWILIO_AUTH_TOKEN: str = config("TWILIO_AUTH_TOKEN", default="")
TWILIO_PHONE_NUMBER: str = config("TWILIO_PHONE_NUMBER", default="")
settings = Settings()