Complete OAuth-based authentication with JWT session management:
Core Services:
- JWT service for access/refresh token creation and verification
- Token store with Redis-backed refresh token revocation
- User service for CRUD operations and OAuth-based creation
- Google and Discord OAuth services with full flow support
API Endpoints:
- GET /api/auth/{google,discord} - Start OAuth flows
- GET /api/auth/{google,discord}/callback - Handle OAuth callbacks
- POST /api/auth/refresh - Exchange refresh token for new access token
- POST /api/auth/logout - Revoke single refresh token
- POST /api/auth/logout-all - Revoke all user sessions
- GET/PATCH /api/users/me - User profile management
- GET /api/users/me/linked-accounts - List OAuth providers
- GET /api/users/me/sessions - Count active sessions
Infrastructure:
- Pydantic schemas for auth/user request/response models
- FastAPI dependencies (get_current_user, get_current_premium_user)
- OAuthLinkedAccount model for multi-provider support
- Alembic migration for oauth_linked_accounts table
Dependencies added: email-validator, fakeredis (dev), respx (dev)
84 new tests, 1058 total passing
26 lines
666 B
Python
26 lines
666 B
Python
"""OAuth provider services for Mantimon TCG.
|
|
|
|
This package contains OAuth integration services for supported providers.
|
|
|
|
Providers:
|
|
- Google: OAuth 2.0 with Google accounts
|
|
- Discord: OAuth 2.0 with Discord accounts
|
|
|
|
Example:
|
|
from app.services.oauth import google_oauth, discord_oauth
|
|
|
|
# Get authorization URL
|
|
auth_url = google_oauth.get_authorization_url(redirect_uri, state)
|
|
|
|
# Exchange code for user info
|
|
user_info = await google_oauth.get_user_info(code, redirect_uri)
|
|
"""
|
|
|
|
from app.services.oauth.discord import discord_oauth
|
|
from app.services.oauth.google import google_oauth
|
|
|
|
__all__ = [
|
|
"google_oauth",
|
|
"discord_oauth",
|
|
]
|