- introduce custom repository exception hierarchy (DuplicateEntryError, IntegrityConstraintError, InvalidInputError) replacing raw ValueError - eliminate all direct repository imports and raw SQL from route layer - add UserService, SessionService, OrganizationService to service layer - add get_stats/get_org_distribution service methods replacing admin inline SQL - fix timing side-channel in authenticate_user via dummy bcrypt check - replace SHA-256 client secret fallback with explicit InvalidClientError - replace assert with InvalidGrantError in authorization code exchange - replace N+1 token revocation loops with bulk UPDATE statements - rename oauth account token fields (drop misleading 'encrypted' suffix) - add Alembic migration 0003 for token field column rename - add 45 new service/repository tests; 975 passing, 94% coverage
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
# app/api/dependencies/services.py
|
|
"""FastAPI dependency functions for service singletons."""
|
|
|
|
from app.services import oauth_provider_service
|
|
from app.services.auth_service import AuthService
|
|
from app.services.oauth_service import OAuthService
|
|
from app.services.organization_service import OrganizationService, organization_service
|
|
from app.services.session_service import SessionService, session_service
|
|
from app.services.user_service import UserService, user_service
|
|
|
|
|
|
def get_auth_service() -> AuthService:
|
|
"""Return the AuthService singleton for dependency injection."""
|
|
from app.services.auth_service import AuthService as _AuthService
|
|
|
|
return _AuthService()
|
|
|
|
|
|
def get_user_service() -> UserService:
|
|
"""Return the UserService singleton for dependency injection."""
|
|
return user_service
|
|
|
|
|
|
def get_organization_service() -> OrganizationService:
|
|
"""Return the OrganizationService singleton for dependency injection."""
|
|
return organization_service
|
|
|
|
|
|
def get_session_service() -> SessionService:
|
|
"""Return the SessionService singleton for dependency injection."""
|
|
return session_service
|
|
|
|
|
|
def get_oauth_service() -> OAuthService:
|
|
"""Return OAuthService for dependency injection."""
|
|
return OAuthService()
|
|
|
|
|
|
def get_oauth_provider_service():
|
|
"""Return the oauth_provider_service module for dependency injection."""
|
|
return oauth_provider_service
|