Automated Action b7392c9694 Add user authentication flow with FastAPI
- Set up FastAPI project structure with main.py and requirements.txt
- Create User model with SQLAlchemy and SQLite database
- Implement JWT token-based authentication system
- Add password hashing with bcrypt
- Create auth endpoints: register, login, and protected /me route
- Set up Alembic for database migrations
- Add health check endpoint with database status
- Configure CORS to allow all origins
- Update README with setup instructions and environment variables
2025-06-20 10:53:35 +00:00

33 lines
832 B
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.api.routes import auth, health
from app.db.session import engine
from app.db.base import Base
app = FastAPI(
title="User Authentication Service",
description="A FastAPI service for user authentication",
version="1.0.0",
openapi_url="/openapi.json"
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
Base.metadata.create_all(bind=engine)
app.include_router(auth.router, prefix="/auth", tags=["authentication"])
app.include_router(health.router, tags=["health"])
@app.get("/")
async def root():
return {
"title": "User Authentication Service",
"documentation": "/docs",
"health_check": "/health"
}