Exemplo n.º 1
0
def authorize_user_context(context, user_id):
    """Ensures a request has permission to access the given user."""
    if is_user_context(context):
        if not context.user_id:
            raise exception.NotAuthorized()
        elif context.user_id != user_id:
            raise exception.NotAuthorized()
Exemplo n.º 2
0
def authorize_project_context(context, project_id):
    """Ensures a request has permission to access the given project."""
    if is_user_context(context):
        if not context.project_id:
            raise exception.NotAuthorized()
        elif context.project_id != project_id:
            raise exception.NotAuthorized()
Exemplo n.º 3
0
 def wrapper(*args, **kwargs):
     if not is_admin_context(args[0]) and not is_user_context(args[0]):
         raise exception.NotAuthorized()
     return f(*args, **kwargs)