繁体   English   中英

比较用户的特定自定义属性

[英]Comparing specific custom-defined attribute of user

对于我想到的XACML策略文档,我有一个主题(用户)和一个对象,每一个都带有标签。 我们称其为myLabel = {[a,b,c], [1,2,3]} 我希望对该标签的各个部分进行比较。

如何定义访问请求和策略中包含此标签的主题和对象,以制定比较此决定的决定?

我希望使用XML而不是JSON或ALFA来声明以上内容。

XACML(和ALFA)带有一组明确定义的数据类型和功能。 例如,XACML定义以下数据类型:

  • 整数
  • 布尔
  • 日期...

现成的数据类型大约有18种。

为了处理这些数据类型,XACML定义了数百种功能,例如:

  • 字符串相等
  • 字符串大于
  • 整数等于
  • ...

XACML中的属性(例如标签,角色或部门)必须具有数据类型。 属性可以是多值的。 换句话说, role = ["manager"]role = ["manager", "employee", "janitor"] 两者都是完全有效的。

就您而言,您所指的值结构如下: {[a,b,c],[1,2,3]} 这不是标准数据类型。 这是一个复杂的对象,因此需要进一步处理(在PEP中?在PIP中?)。 您如何考虑将其传递给PDP?

假设我们有简单的值,例如label ='2'。 要将用户的标签与资源的标签进行比较,并在它们相等时授予访问权限,请编写以下代码:

ALFA

    /**
     * Control access based on labels
     */
    policy labelAccessControl{
        apply firstApplicable
        rule allowIfSameLabel{
            permit
            condition user.label == object.label
        }

    }

等效XACML XML

<?xml version="1.0" encoding="UTF-8"?><!--This file was generated by the 
    ALFA Plugin for Eclipse from Axiomatics AB (http://www.axiomatics.com). --><!--Any modification to this file will 
    be lost upon recompilation of the source ALFA file -->
<xacml3:Policy
    xmlns:xacml3="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
    PolicyId="http://axiomatics.com/alfa/identifier/com.axiomatics.labelAccessControl"
    RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable"
    Version="1.0">
    <xacml3:Description>Control access based on labels</xacml3:Description>
    <xacml3:PolicyDefaults>
        <xacml3:XPathVersion>http://www.w3.org/TR/1999/REC-xpath-19991116
        </xacml3:XPathVersion>
    </xacml3:PolicyDefaults>
    <xacml3:Target />
    <xacml3:Rule Effect="Permit"
        RuleId="com.axiomatics.labelAccessControl.allowIfSameLabel">
        <xacml3:Description />
        <xacml3:Target />
        <xacml3:Condition>
            <xacml3:Apply
                FunctionId="urn:oasis:names:tc:xacml:3.0:function:any-of-any">
                <xacml3:Function
                    FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal" />
                <xacml3:AttributeDesignator
                    AttributeId="com.axiomatics.user.label"
                    Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
                    DataType="http://www.w3.org/2001/XMLSchema#string"
                    MustBePresent="false" />
                <xacml3:AttributeDesignator
                    AttributeId="com.axiomatics.object.label"
                    Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
                    DataType="http://www.w3.org/2001/XMLSchema#string"
                    MustBePresent="false" />
            </xacml3:Apply>
        </xacml3:Condition>
    </xacml3:Rule>
</xacml3:Policy>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM