比较XACML策略中的两个多元素属性

时间:2019-05-31 13:36:50

标签: xacml xacml3 alfa pdp authzforce

请考虑一个具有定义如下的标签的主题:

subject/object label = [i1, i2, ..., in],其中i是另一个主题的subjectId

在策略(ALFA / XACML)中,如何对主题标签和对象标签进行比较,以使两个列表中的任何元素都不相同。

例如:

subject_label = [i2, i4, i9]
object_label  = [i1, i3, i7, i9]

由于两个标签都包含DENY,因此最终的决定将是i9。如果在任何列表中均未找到匹配项,则访问结果将为PERMIT

1 个答案:

答案 0 :(得分:1)

您要使用的是tasks: - name: DEBUG debug: msg: 'KEY: {{ item.key }}, VALUE: {{ item.value.0.is_active }}' loop: '{{ lookup("dict", DOMAIN_GROUPS_ASSIGNMENT) }}' (或等效于其他数据类型)。此函数有两个参数:

  • 一袋字符串类型
  • 一袋字符串类型

如果第一个袋子中至少有一个值等于第二个袋子中的一个值,则返回true。对于字符串,比较区分大小写。

stringAtLeastOneMemberOf

这是XACML / XML表示形式:

namespace com.axiomatics{
    /**
     * Ths policy will checks the contents of the user label and the the resource label.
     * It will deny access if there is at least one value in the user label equal to at least
     * one value in the resource label.
     */
    policy denyIfSameContent{
        apply firstApplicable
        /**
         * This rule will deny access is user.label contains at least 1 value that is also present
         * in object.label 
         */
        rule denyIfSameContent{
            deny
            condition stringAtLeastOneMemberOf(user.label, object.label)
        }
    }
}
相关问题