mockapi/dependencies.py
2026-03-16 05:47:01 +00:00

22 lines
724 B
Python

from fastapi import Depends, HTTPException, status
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
from sqlalchemy.ext.asyncio import AsyncSession
from database import get_db
security = HTTPBearer(auto_error=False)
async def get_current_user(
credentials: HTTPAuthorizationCredentials = Depends(security),
db: AsyncSession = Depends(get_db)
):
"""Dependency to get current user (admin)."""
# TODO: Implement proper authentication
# For now, just a placeholder
if not credentials:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Not authenticated"
)
# Verify token or session
return {"username": "admin"}