Files
xiaoxia-saas/apps/api/app/middleware/auth.py
T
API文档维护Agent e3fb518ab2
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Lint (pull_request) Has been cancelled
refactor: remove all workspace_id references from codebase
- Remove workspace_id from Pydantic models in project_management routes
- Remove workspace_id from SQLAlchemy and SQLite project management repos
- Remove workspace_id from worker tasks (storage keys, entity creation)
- Remove workspace_id from video dedup and title usage modules
- Remove workspace_id from generation and ingest worker tasks
- Clean workspace_id from all test files and scripts
- Remove workspace-specific test files (list_workspaces, workspace repos)

Task: #14 workspace_id 残留清理
2026-06-27 22:52:09 +08:00

39 lines
1.2 KiB
Python

"""
Authentication dependency compatibility layer.
Canonical bearer-token parsing lives in app.auth. This module remains only so
legacy imports have a safe target while workspace dependencies are rebuilt.
"""
from __future__ import annotations
from app.auth import AuthenticatedUser
from app.auth import get_current_user as get_authenticated_user
from app.dependencies import get_user_repository
from fastapi import Depends
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from packages.domain.entities import User
from packages.ports.user_repository import UserRepository
optional_bearer_scheme = HTTPBearer(auto_error=False)
async def get_current_user(
authenticated_user: AuthenticatedUser = Depends(get_authenticated_user),
) -> User:
return authenticated_user.user
async def get_current_user_optional(
credentials: HTTPAuthorizationCredentials | None = Depends(optional_bearer_scheme),
user_repository: UserRepository = Depends(get_user_repository),
) -> User | None:
if credentials is None:
return None
try:
authenticated_user = await get_authenticated_user(credentials, user_repository)
except HTTPException:
return None
return authenticated_user.user