e3fb518ab2
- 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 残留清理
39 lines
1.2 KiB
Python
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
|