Ejemplo n.º 1
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 exception.NotAuthorized()
        elif context.quota_class != class_name:
            raise exception.NotAuthorized()
Ejemplo 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()
Ejemplo n.º 3
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()
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
 def index(self, req):
     raise exception.NotAuthorized()