22 lines
576 B
Python
22 lines
576 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 Auth = Annotated[str, Depends(auth_method())]
|
|
|
|
def storage():
|
|
stf = config.StorageFactory(config.settings)
|
|
return stf(config.settings.dbschema)
|
|
|
|
def auth_method():
|
|
auth = auth_config.auth_methods.get(auth_config.settings.auth_method)
|
|
return auth
|
|
|