Use UserContext from artdag_common, remove duplicate
- Updated requirements.txt to use art-common@11aa056 with l2_server field - All routers now import UserContext from artdag_common - Removed duplicate UserContext from auth_service.py - dependencies.py sets l2_server from settings on user context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -64,10 +64,15 @@ async def get_current_user(request: Request) -> Optional[UserContext]:
|
||||
# Try header first (API clients)
|
||||
ctx = get_user_from_header(request)
|
||||
if ctx:
|
||||
# Add l2_server from settings
|
||||
ctx.l2_server = settings.l2_server
|
||||
return ctx
|
||||
|
||||
# Fall back to cookie (browser)
|
||||
return get_user_from_cookie(request)
|
||||
ctx = get_user_from_cookie(request)
|
||||
if ctx:
|
||||
ctx.l2_server = settings.l2_server
|
||||
return ctx
|
||||
|
||||
|
||||
async def require_auth(request: Request) -> UserContext:
|
||||
|
||||
@@ -15,8 +15,8 @@ import yaml
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from pydantic import BaseModel
|
||||
|
||||
from artdag_common.middleware.auth import UserContext
|
||||
from ..dependencies import require_auth, get_redis_client, get_cache_manager
|
||||
from ..services.auth_service import UserContext
|
||||
|
||||
router = APIRouter()
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -14,12 +14,13 @@ from pydantic import BaseModel
|
||||
|
||||
from artdag_common import render
|
||||
from artdag_common.middleware import wants_html, wants_json
|
||||
from artdag_common.middleware.auth import UserContext
|
||||
|
||||
from ..dependencies import (
|
||||
require_auth, get_templates, get_redis_client,
|
||||
get_cache_manager, get_current_user
|
||||
)
|
||||
from ..services.auth_service import UserContext, AuthService
|
||||
from ..services.auth_service import AuthService
|
||||
from ..services.cache_service import CacheService
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@@ -13,9 +13,10 @@ from pydantic import BaseModel
|
||||
|
||||
from artdag_common import render
|
||||
from artdag_common.middleware import wants_html, wants_json
|
||||
from artdag_common.middleware.auth import UserContext
|
||||
|
||||
from ..dependencies import require_auth, get_templates, get_redis_client, get_cache_manager
|
||||
from ..services.auth_service import UserContext, AuthService
|
||||
from ..services.auth_service import AuthService
|
||||
from ..services.recipe_service import RecipeService
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@@ -16,12 +16,12 @@ from pydantic import BaseModel
|
||||
|
||||
from artdag_common import render
|
||||
from artdag_common.middleware import wants_html, wants_json
|
||||
from artdag_common.middleware.auth import UserContext
|
||||
|
||||
from ..dependencies import (
|
||||
require_auth, get_templates, get_current_user,
|
||||
get_redis_client, get_cache_manager
|
||||
)
|
||||
from ..services.auth_service import UserContext
|
||||
from ..services.run_service import RunService
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@@ -12,9 +12,9 @@ from pydantic import BaseModel
|
||||
|
||||
from artdag_common import render
|
||||
from artdag_common.middleware import wants_html, wants_json
|
||||
from artdag_common.middleware.auth import UserContext
|
||||
|
||||
from ..dependencies import get_database, get_current_user, require_auth, get_templates
|
||||
from ..services.auth_service import UserContext
|
||||
from ..services.storage_service import StorageService, STORAGE_PROVIDERS_INFO, VALID_PROVIDER_TYPES
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@@ -6,10 +6,10 @@ import hashlib
|
||||
import base64
|
||||
import json
|
||||
from typing import Optional
|
||||
from dataclasses import dataclass
|
||||
|
||||
import httpx
|
||||
|
||||
from artdag_common.middleware.auth import UserContext
|
||||
from ..config import settings
|
||||
|
||||
|
||||
@@ -21,15 +21,6 @@ REVOKED_KEY_PREFIX = "artdag:revoked:"
|
||||
USER_TOKENS_PREFIX = "artdag:user_tokens:"
|
||||
|
||||
|
||||
@dataclass
|
||||
class UserContext:
|
||||
"""User context from token."""
|
||||
username: str
|
||||
actor_id: str
|
||||
token: Optional[str] = None
|
||||
l2_server: Optional[str] = None
|
||||
|
||||
|
||||
class AuthService:
|
||||
"""Service for authentication and token management."""
|
||||
|
||||
|
||||
@@ -11,4 +11,4 @@ markdown>=3.5.0
|
||||
# Core artdag from GitHub
|
||||
git+https://github.com/gilesbradshaw/art-dag.git
|
||||
# Shared components
|
||||
git+https://git.rose-ash.com/art-dag/common.git@932abb8
|
||||
git+https://git.rose-ash.com/art-dag/common.git@11aa056
|
||||
|
||||
Reference in New Issue
Block a user