inventorymgr/accesscontrol.py
def requires_permissions(
    *permissions: str,
) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
    """Wrap a view and check for permissions, raising APIError if user does not have them."""

    def outer(to_be_wrapped: Callable[..., Any]) -> Callable[..., Any]:
        @functools.wraps(to_be_wrapped)
        def inner(*args: Any, **kwargs: Any) -> Any:
            user = get_session_user()
            if not all(getattr(user, p, False) for p in permissions):
                raise APIError(reason="insufficient_permissions", status_code=403)
            return to_be_wrapped(*args, **kwargs)

        return inner

    return outer
Wrap a view and check for permissions, raising APIError if user does not have them.
Wrap a view and check for permissions, raising APIError if user does not have them.
Wrap a view and check for permissions raising APIError if user does not have them .
def requires_permissions(
    *permissions: str,
) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
    def outer(to_be_wrapped: Callable[..., Any]) -> Callable[..., Any]:
        @functools.wraps(to_be_wrapped)
        def inner(*args: Any, **kwargs: Any) -> Any:
            user = get_session_user()
            if not all(getattr(user, p, False) for p in permissions):
                raise APIError(reason="insufficient_permissions", status_code=403)
            return to_be_wrapped(*args, **kwargs)
        return inner
    return outer
def requires_permissions ( * permissions : str , ) -> Callable [ [ Callable [ ... , Any ] ] , Callable [ ... , Any ] ] : def outer ( to_be_wrapped : Callable [ ... , Any ] ) -> Callable [ ... , Any ] : @ functools . wraps ( to_be_wrapped ) def inner ( * args : Any , ** kwargs : Any ) -> Any : user = get_session_user ( ) if not all ( getattr ( user , p , False ) for p in permissions ) : raise APIError ( reason = "insufficient_permissions" , status_code = 403 ) return to_be_wrapped ( * args , ** kwargs ) return inner return outer
Wrap a view and check for permissions, raising APIError if user does not have them.
Wrap a view and check for permissions raising APIError if user does not have them .
"""Wrap a view and check for permissions, raising APIError if user does not have them."""
permissions
str