【问题标题】:Not Applicable XACML policy semantic error不适用 XACML 策略语义错误
【发布时间】:2015-09-15 13:14:24
【问题描述】:

我目前正在尝试使用 XACML 编写一个简单的策略。 不幸的是,我的 XACML 引擎似乎没有找到适用于我的请求的策略。

我所做的如下:

政策:

    <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
    PolicyId="testPolicy-Quota-Storage"
    RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:permit-overrides"
    Version="3.0">
<Target></Target>
    <Rule Effect="Permit" RuleId="Permit-Quota-Storage">
        <Description>Quota-Storage Rule : request for storage > 2500mb implies
            that if the profile of a user allows it, the storage plan is scaled
            up
        </Description>
        <Target>
            <AnyOf>
                <AllOf>


                    <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">premium</AttributeValue>
                        <AttributeDesignator
                            AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id-qualifier"
                            Category="urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject"
                            DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false" />
                    </Match>


                    <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">store</AttributeValue>
                        <AttributeDesignator
                            AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id"
                            Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action"
                            DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false" />
                    </Match>
                    <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:integer-greater-than">

                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer">2500</AttributeValue>

                        <AttributeDesignator
                            AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id"
                            Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
                            DataType="http://www.w3.org/2001/XMLSchema#integer"
                            MustBePresent="false" />

                    </Match>

                </AllOf>
            </AnyOf>
        </Target>

    </Rule>
    <Rule Effect="Deny" RuleId="Deny-1">
        <Target>
            <AnyOf>
                <AllOf>
                    <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">fixed</AttributeValue>
                        <AttributeDesignator
                            AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id-qualifier"
                            Category="urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject"
                            DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false" />
                    </Match>
                </AllOf>
            </AnyOf>

        </Target>
    </Rule>

</Policy>

请求:

 <xacml-ctx:Request ReturnPolicyIdList="false" CombinedDecision="false" xmlns:xacml-ctx="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
   <xacml-ctx:Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" >
      <xacml-ctx:Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" IncludeInResult="false">
         <xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer">2500</xacml-ctx:AttributeValue>
      </xacml-ctx:Attribute>
   </xacml-ctx:Attributes>
   <xacml-ctx:Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" >
      <xacml-ctx:Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" IncludeInResult="false">
         <xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">store</xacml-ctx:AttributeValue>
      </xacml-ctx:Attribute>
   </xacml-ctx:Attributes>
   <xacml-ctx:Attributes Category="urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject" >
      <xacml-ctx:Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id-qualifier" IncludeInResult="false">
         <xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">fixed</xacml-ctx:AttributeValue>
      </xacml-ctx:Attribute>
      <xacml-ctx:Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" IncludeInResult="false">
         <xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">alice@company.com</xacml-ctx:AttributeValue>
      </xacml-ctx:Attribute>
   </xacml-ctx:Attributes>
</xacml-ctx:Request>

【问题讨论】:

    标签: authorization access-control xacml xacml3 abac


    【解决方案1】:

    我使用以下方法检查了您的政策:

    • 公理策略管理点
    • 通过 Notepad++ 的标准 XML 模式验证器插件

    验证错误

    在这两种情况下,验证都返回验证错误:

    错误:元素“{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Rule”: 该元素不是预期的。预期是( {urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}描述, {urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}PolicyIssuer, {urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}PolicyDefaults, {urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}目标)。

    您编写的策略不是有效的 XACML 3.0。如果您手动编写策略,您将丢失一些元素。如果您使用工具编写策略,我建议您更改工具。例如,使用 Eclipse 的 ALFA 插件。用它编写策略很容易。 See here。它可免费用于非商业用途。

    我修正了您添加缺失元素的政策。我运行了另一个验证并得到了

    错误:元素 '{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Match':这个元素 预计不会。预期为 ( {urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AnyOf)。

    这意味着您在规则Deny-1 中的目标也无效。您缺少 Match 元素周围的 AllOf/AnyOf 元素。

    公理 PAP 中的政策

    一旦我修复了这 2 个错误,我就可以在 Axiomatics PAP 中导入策略。导入后,UI 会按如下方式显示您的策略:

    根据策略模拟请求

    然后我根据政策运行了您的请求

    我已经可以看到,您的请求实际上是一个多重决策请求,如 blog post 中所述。您可能不打算创建这样的请求,而是创建具有多个主题属性的请求。因此,请求应该是

    <xacml-ctx:Request ReturnPolicyIdList="false" CombinedDecision="false" xmlns:xacml-ctx="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
       <xacml-ctx:Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" >
          <xacml-ctx:Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" IncludeInResult="false">
             <xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer">2600</xacml-ctx:AttributeValue>
          </xacml-ctx:Attribute>
       </xacml-ctx:Attributes>
       <xacml-ctx:Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" >
          <xacml-ctx:Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" IncludeInResult="false">
             <xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">store</xacml-ctx:AttributeValue>
          </xacml-ctx:Attribute>
       </xacml-ctx:Attributes>
       <xacml-ctx:Attributes Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" >
          <xacml-ctx:Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id-qualifier" IncludeInResult="false">
             <xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">premium</xacml-ctx:AttributeValue>
          </xacml-ctx:Attribute>
          <xacml-ctx:Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" IncludeInResult="false">
             <xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">alice@company.com</xacml-ctx:AttributeValue>
          </xacml-ctx:Attribute>
       </xacml-ctx:Attributes>
    </xacml-ctx:Request>
    

    现在评估结果仍然是NotApplicable,正如您自己指出的那样。原因是你没有标准化你的价值观。例如,您的请求使用premium,但您的策略使用premium(whitespace)。空格很重要。

    最后,一旦这个错误得到修复,你会得到 NotApplicable 因为你根本没有发送正确的值,例如premium 和 2500。您可以在此屏幕截图中看到评估跟踪。

    【讨论】:

    • 它的功能大于功能,所以使用 2600 应该没问题,但我的引擎仍然提供 NotApplicable,我刚刚安装的 wso2 身份管理器却给我拒绝拒绝请求。但不适用于许可证。我用当前使用的帖子更新了我的主要帖子。
    • 你用的是什么引擎?
    • WSO2 IS 使用 Balana,因此您不应该注意到任何行为差异。尝试另一个引擎,例如Heras AF、SunXACML 或 Axiomatics。
    • 好吧,Axiomatics 不是免费软件,SunXacml 我不兼容 xacml 3..Heras 现在与我的应用程序不兼容,所以......我会看看我能做什么......
    • Balana 也不符合 XACML 3.0(部分 XACML 3.0 并且非常有问题)。那就试试 AT&T。哦,没有免费的午餐
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多