示例#1
0
def enforce(context, action, target, plugin=None):
    """Verifies that the action is valid on the target in this context.

    :param context: quantum context
    :param action: string representing the action to be checked
        this should be colon separated for clarity.
    :param target: dictionary representing the object of the action
        for object creation this should be a dictionary representing the
        location of the object e.g. ``{'project_id': context.project_id}``
    :param plugin: quantum plugin used to retrieve information required
        for augmenting the target

    :raises quantum.exceptions.PolicyNotAllowed: if verification fails.
    """

    init()

    real_target = _build_target(action, target, plugin, context)
    match_list = _build_match_list(action, real_target)
    credentials = context.to_dict()

    policy.enforce(match_list,
                   real_target,
                   credentials,
                   exceptions.PolicyNotAuthorized,
                   action=action)
示例#2
0
def enforce(context, action, target, plugin=None):
    """Verifies that the action is valid on the target in this context.

    :param context: quantum context
    :param action: string representing the action to be checked
        this should be colon separated for clarity.
    :param target: dictionary representing the object of the action
        for object creation this should be a dictionary representing the
        location of the object e.g. ``{'project_id': context.project_id}``
    :param plugin: quantum plugin used to retrieve information required
        for augmenting the target

    :raises quantum.exceptions.PolicyNotAllowed: if verification fails.
    """

    init()
    real_target = _build_target(action, target, plugin, context)
    match_list = _build_match_list(action, real_target)
    credentials = context.to_dict()
    policy.enforce(match_list, real_target, credentials, exceptions.PolicyNotAuthorized, action=action)
示例#3
0
文件: policy.py 项目: LuizOz/quantum
def enforce(context, action, target):
    """Verifies that the action is valid on the target in this context.

    :param context: quantum context
    :param action: string representing the action to be checked
        this should be colon separated for clarity.
    :param object: dictionary representing the object of the action
        for object creation this should be a dictionary representing the
        location of the object e.g. ``{'project_id': context.project_id}``

    :raises quantum.exceptions.PolicyNotAllowed: if verification fails.
    """

    init()

    match_list = ('rule:%s' % action,)
    credentials = context.to_dict()

    policy.enforce(match_list, target, credentials,
                   exceptions.PolicyNotAuthorized, action=action)
示例#4
0
文件: policy.py 项目: LuizOz/quantum
def enforce(context, action, target):
    """Verifies that the action is valid on the target in this context.

    :param context: quantum context
    :param action: string representing the action to be checked
        this should be colon separated for clarity.
    :param object: dictionary representing the object of the action
        for object creation this should be a dictionary representing the
        location of the object e.g. ``{'project_id': context.project_id}``

    :raises quantum.exceptions.PolicyNotAllowed: if verification fails.
    """

    init()

    match_list = ('rule:%s' % action, )
    credentials = context.to_dict()

    policy.enforce(match_list,
                   target,
                   credentials,
                   exceptions.PolicyNotAuthorized,
                   action=action)
示例#5
0
文件: policy.py 项目: vbannai/quantum
def check(context, action, target):
    """Verifies that the action is valid on the target in this context.

    :param context: quantum context
    :param action: string representing the action to be checked
        this should be colon separated for clarity.
    :param object: dictionary representing the object of the action
        for object creation this should be a dictionary representing the
        location of the object e.g. ``{'project_id': context.project_id}``

    :return: Returns True if access is permitted else False.
    """
    init()
    match_list = ('rule:%s' % action,)
    credentials = context.to_dict()
    return policy.enforce(match_list, target, credentials)
示例#6
0
def check(context, action, target, plugin=None):
    """Verifies that the action is valid on the target in this context.

    :param context: quantum context
    :param action: string representing the action to be checked
        this should be colon separated for clarity.
    :param target: dictionary representing the object of the action
        for object creation this should be a dictionary representing the
        location of the object e.g. ``{'project_id': context.project_id}``
    :param plugin: quantum plugin used to retrieve information required
        for augmenting the target

    :return: Returns True if access is permitted else False.
    """
    init()
    real_target = _build_target(action, target, plugin, context)
    match_list = _build_match_list(action, real_target)
    credentials = context.to_dict()
    return policy.enforce(match_list, real_target, credentials)
示例#7
0
文件: policy.py 项目: missall/quantum
def check(context, action, target, plugin=None):
    """Verifies that the action is valid on the target in this context.

    :param context: quantum context
    :param action: string representing the action to be checked
        this should be colon separated for clarity.
    :param target: dictionary representing the object of the action
        for object creation this should be a dictionary representing the
        location of the object e.g. ``{'project_id': context.project_id}``
    :param plugin: quantum plugin used to retrieve information required
        for augmenting the target

    :return: Returns True if access is permitted else False.
    """
    init()
    real_target = _build_target(action, target, plugin, context)
    match_list = _build_match_list(action, real_target)
    credentials = context.to_dict()
    return policy.enforce(match_list, real_target, credentials)
示例#8
0
文件: policy.py 项目: LuizOz/quantum
def check(context, action, target):
    """Verifies that the action is valid on the target in this context.

    :param context: quantum context
    :param action: string representing the action to be checked
        this should be colon separated for clarity.
    :param object: dictionary representing the object of the action
        for object creation this should be a dictionary representing the
        location of the object e.g. ``{'project_id': context.project_id}``

    :return: Returns True if access is permitted else False.
    """

    init()

    match_list = ('rule:%s' % action, )
    credentials = context.to_dict()

    return policy.enforce(match_list, target, credentials)