Exemple #1
0
def Security(  # noqa: N802
    dependency: Optional[Callable[..., Any]] = None,
    *,
    scopes: Optional[Sequence[str]] = None,
    use_cache: bool = True,
) -> Any:
    return params.Security(dependency=dependency, scopes=scopes, use_cache=use_cache)
Exemple #2
0
def Security(  # noqa: N802
        dependency: Callable = None,
        *,
        scopes: Sequence[str] = None,
        use_cache: bool = True) -> Any:
    return params.Security(dependency=dependency,
                           scopes=scopes,
                           use_cache=use_cache)
Exemple #3
0
def require_superuser() -> Sequence[params.Depends]:
    """
    Returns a list of dependencies containing one that will require superuser access, *UNLESS*
    api_settings indicates otherwise (for development purposes).

    (In that case, no dependencies are added but a warning is emitted.)
    """
    if get_api_settings().disable_superuser_dependency:
        logger.warning(f"*** require_superuser is DISABLED ***")
        return []
    return [
        params.Security(get_jwt_user,
                        scopes=[get_auth_settings().superuser_scope])
    ]
Exemple #4
0
def Security(  # noqa: N802
        dependency: Callable = None, scopes: Sequence[str] = None) -> Any:
    return params.Security(dependency=dependency, scopes=scopes)