【问题标题】:XACML Policy and RequestXACML 政策和要求
【发布时间】:2014-04-29 18:05:19
【问题描述】:

首先我想提一下,这肯定是一个新手问题,但我已经找了好几个小时了,但我没有答案。

我刚开始出于学术目的尝试 XACML。我使用 wso2-is 提供的编辑器来编写一些策略并根据一些请求评估它们。

我创建此政策是为了表明主题 u 可以从资源 d

读取或写入
     <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="test-bis" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-overrides" Version="1.0">
   <Target/>
   <Rule Effect="Permit" RuleId="read-or-write">
      <Target>
         <AnyOf>
            <AllOf>
               <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                  <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">d</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#string" MustBePresent="true"/>
               </Match>
            </AllOf>
         </AnyOf>
      </Target>
      <Condition>
         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
            <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of">
               <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag">
                  <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">read</AttributeValue>
                  <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">write</AttributeValue>
               </Apply>
               <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="true"/>
            </Apply>
            <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:any-of">
               <Function FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal"/>
               <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">u</AttributeValue>
               <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"/>
            </Apply>
         </Apply>
      </Condition>
   </Rule>
   <Rule Effect="Deny" RuleId="deny"/>
</Policy>

在匹配这个简单的请求“Can u read from d”时,我得到了不适用的结果! 这是请求:

 <Request xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" CombinedDecision="false" ReturnPolicyIdList="false">
<Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action">
<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" IncludeInResult="false">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">read</AttributeValue>
</Attribute>
</Attributes>
<Attributes Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject">
<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" IncludeInResult="false">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">u</AttributeValue>
</Attribute>
</Attributes>
<Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" IncludeInResult="false">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">d</AttributeValue>
</Attribute>
</Attributes>
</Request> 

谁能帮助我理解我做错了什么?

谢谢大家!

【问题讨论】:

    标签: wso2is xacml xacml3


    【解决方案1】:

    我测试了您在Axiomatics Policy Server 中发送的政策和请求(免责声明:我为 Axiomatics 工作)。答案实际上应该是Deny。两条规则都触发了。您将策略中的规则与deny-overrides 组合算法相结合,这意味着Deny 胜过Permit

    您可以在下面看到 APS 中策略模拟的屏幕截图,其中显示了两个规则被触发并且第二个规则胜过第一个规则。

    如果您有兴趣更好地理解组合算法,这里是deny-overrides 的“真值表”:

    【讨论】:

    • 感谢大卫的这些澄清和算法表。我现在更了解事情了。顺便说一句,既然你在为公理工作,你能告诉我如何获得免费的 ALFA Plugin for Eclipse 吗? (我自 3 月 21 日起注册并等待下载链接 :-))
    • 按您的方式发送 :-)
    • 我们在 YouTube 上有 ALFA 教程:我们在 YouTube 上有教程:youtube.com/…
    【解决方案2】:

    当您收到“不适用”时,您的策略似乎未在 WSO2 IS 中启用或未升级为 PDP 进行测试。只需检查策略是否已启用并升级为 PDP 进行测试。您也可以在不升级到 PDP 的情况下测试策略,但在这两种情况下,它都应该处于启用模式。

    我在 WSo2 IS 4.0.0 中尝试了您的策略,并给出了“拒绝”。是的,正如大卫所说,因为您的策略组合算法是“拒绝覆盖”,根据您的默认规则,它总是得到“拒绝”,如下所示:

    <Rule Effect="Deny" RuleId="deny"/>
    

    因此,要么您需要将策略组合算法设置为“permit-overrides”,要么删除最后一条规则。

    【讨论】:

    • 您好 Yusuf,感谢您的帮助。我不相信需要启用该策略以在 WSO2 IS 中尝试它,所以我刚刚重新启动了服务器,现在我被拒绝了。对于否认,我将在单独的回复中解释我的担忧。
    • 其实不要使用permit-overrides。使用先适用。如果您执行 Permit-overrides 并且 Deny-rule 确实触发了,那么您将错误地获得 Permit。
    • 另外,添加 Permit-overrides 归结为删除最后一条规则。
    • 谢谢你们俩。该问题已通过保持通过规则拒绝并将组合算法更改为首先适用来解决。
    【解决方案3】:

    您的要求很好,这是您的要求的政策。

    <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="9f654de2-06d3-45c9-bb7f-947c9a9b247a" RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable" Version="1.0">
    <Target>
    <AnyOf>
    <AllOf>
    <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">d</AttributeValue>
    <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:resource:root-resource-id" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"/>
    </Match>
    </AllOf>
    </AnyOf>
    </Target>
    <Rule Effect="Permit" RuleId="Rule_write">
    <Condition>
    <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
    <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of">
    <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag">
    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">write</AttributeValue>
    </Apply>
    <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="true"/>
    </Apply>
    <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of">
    <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag">
    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">u</AttributeValue>
    </Apply>
    <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"/>
    </Apply>
    </Apply>
    </Condition>
    </Rule>
    <Rule Effect="Permit" RuleId="Rule_read">
    <Condition>
    <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
    <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of">
    <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag">
    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">read</AttributeValue></Apply>
    <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="true"/>
    </Apply><Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of">
    <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag">
    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">u</AttributeValue></Apply>
    <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"/>
    </Apply>
    </Apply>
    </Condition>
    </Rule>
    <Rule Effect="Deny" RuleId="Rule_Deny_All"/>
    </Policy>
    

    【讨论】:

    • 该政策不适用于 WSO2 IS,今晚我会仔细研究一下。但是我认为问题来自我的请求:我认为我们不能为同一个访问请求定义两个操作(我将为此创建一个单独的 SO 问题)。
    • 您是否在 wso2IS 中发布了该策略?
    • 是的,我得到:&lt;Result&gt; &lt;Decision&gt;Indeterminate&lt;/Decision&gt; &lt;Status&gt; &lt;StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:processing-error"/&gt; &lt;StatusMessage&gt;Couldn't find AttributeDesignator attribute&lt;/StatusMessage&gt; &lt;/Status&gt; &lt;/Result&gt;
    • 这意味着 wso2is 策略查找器可能无法获取此策略
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-23
    • 1970-01-01
    • 2015-05-02
    • 2014-05-19
    • 2019-11-23
    相关资源
    最近更新 更多