py-scopes/scopes/api/deps.py

23 lines
593 B
Python

# scopes.api.deps
"""Common dependencies and other definitions for Web API"""
from fastapi import Depends
from typing import Annotated
from scopes import config
from scopes.api.auth import config as auth_config
from scopes.storage import common
type Storage = Annotated[common.Storage, Depends(storage)]
type AuthUser = Annotated[str, Depends(auth_user)]
def storage():
stf = config.StorageFactory(config.settings)
return stf(config.settings.dbschema)
def auth_user():
auth = auth_config.auth_methods.get(auth_config.settings.auth_method)
if auth:
return auth()