Esempio n. 1
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 exceptions.NotAuthorized()
        elif context.project_id != project_id:
            raise exceptions.NotAuthorized()
Esempio n. 2
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 exceptions.NotAuthorized()
        elif context.user_id != user_id:
            raise exceptions.NotAuthorized()
Esempio n. 3
0
def authorize_quota_class_context(context, class_name):
    """Ensures a request has permission to access the given quota class."""
    if _is_user_context(context):
        if not context.quota_class:
            raise exceptions.NotAuthorized()
        elif context.quota_class != class_name:
            raise exceptions.NotAuthorized()
Esempio n. 4
0
 def wrapper(*args, **kwargs):
     if not _is_admin_context(args[0]) and not _is_user_context(args[0]):
         raise exceptions.NotAuthorized()
     return f(*args, **kwargs)