nanochat/services/auth
Manmohan b5fbebb63f
Merge pull request #26 from manmohan659/fix/missing-models
fix: add missing SQLAlchemy models to auth and chat-api
2026-04-16 16:50:22 -04:00
..
src fix: add missing models/ dirs to auth and chat-api services 2026-04-16 13:50:08 -07:00
Dockerfile fix(docker): add structlog + prometheus deps to auth and chat-api Dockerfiles 2026-04-16 13:46:53 -07:00
pyproject.toml feat(observability): Prometheus + Grafana + Loki stack for samosaChaat (#9) 2026-04-16 12:29:16 -07:00
README.md feat(auth): OAuth2 + JWT auth service with Alembic migrations (#5 #7) 2026-04-16 11:47:00 -07:00

samosaChaat Auth Service

FastAPI microservice providing OAuth2 login (Google + GitHub) and JWT session management for samosaChaat (Issue #5).

Endpoints

Method Path Purpose
GET /auth/google Redirect to Google consent
GET /auth/google/callback Complete Google flow, upsert user, issue tokens
GET /auth/github Redirect to GitHub consent
GET /auth/github/callback Complete GitHub flow, upsert user, issue tokens
POST /auth/refresh Exchange refresh cookie for new access token
GET /auth/me Current user profile (Bearer JWT)
PUT /auth/me Update name / avatar (Bearer JWT)
POST /auth/validate Internal JWT validation (service-to-service)
GET /auth/health Liveness probe

Environment

DATABASE_URL=postgresql+asyncpg://user:pass@host/db
GOOGLE_CLIENT_ID=...
GOOGLE_CLIENT_SECRET=...
GITHUB_CLIENT_ID=...
GITHUB_CLIENT_SECRET=...
JWT_PRIVATE_KEY=<RS256 PEM>
JWT_PUBLIC_KEY=<RS256 PEM>
FRONTEND_URL=http://localhost:3000
INTERNAL_API_KEY=<shared secret for /auth/validate>

Local development

uv sync
uv run uvicorn src.main:app --reload --port 8001
uv run pytest

Database schema is managed by Alembic at db/migrations:

DATABASE_URL=... uv run alembic -c db/alembic.ini upgrade head