
- 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
29 lines
941 B
Python
29 lines
941 B
Python
from sqlalchemy import Column, Integer, String, DateTime, Enum, Boolean
|
|
from sqlalchemy.sql import func
|
|
from app.db.base import Base
|
|
import enum
|
|
|
|
|
|
class AuthProvider(enum.Enum):
|
|
PHONE = "PHONE"
|
|
GOOGLE = "GOOGLE"
|
|
APPLE = "APPLE"
|
|
EMAIL = "EMAIL"
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
phone_number = Column(String, unique=True, nullable=True, index=True)
|
|
email = Column(String, unique=True, nullable=True, index=True)
|
|
name = Column(String, nullable=True)
|
|
password_hash = Column(String, nullable=True)
|
|
auth_provider = Column(Enum(AuthProvider), nullable=False)
|
|
is_active = Column(Boolean, default=True)
|
|
is_verified = Column(Boolean, default=False)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(
|
|
DateTime(timezone=True), server_default=func.now(), onupdate=func.now()
|
|
)
|