【问题标题】:XACML PolicySet and Request with exampleXACML PolicySet 和 Request 示例
【发布时间】:2015-01-15 23:52:17
【问题描述】:

我是 XACML 的新手。我计划使用 XACML 策略和 Wso2 ID 服务器在我们的组织应用程序中实施 RBAC。我已经阅读了许多关于使用 wso2 创建不同的不同 XACML 策略的文章,并且我也尝试了许多策略示例。但是在浏览了所有可用示例之后,我没有找到创建 XACML 策略集和重新使用策略集的正确方法。我自己尝试创建 XACML PolicySet,但是当我尝试在 wso2 Id 服务器中执行此策略集时,它每次都会给我“不适用”错误。我尝试了很多以不同方式创建 XACML 策略集但是当我创建请求时为此,它不会给我正确的结果。 帮助我给出 XACML 策略集的正确示例及其请求。

在这里我添加了我的策略集和策略以及它的请求。请让我知道其中有什么问题。

在 wso2Id 中创建的角色是:- testRole 并将此角色分配给 testUser

PolicySet 是:-

<PolicySet xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"  PolicyCombiningAlgId="urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:permit-overrides" PolicySetId="PolicySetExample" Version="1.0">
   <Description>TestPolicySet</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">H1</AttributeValue>
               <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:environment:environment-id" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
            </Match>
         </AllOf>
      </AnyOf>
   </Target>
   <PolicyIdReference>ComplexPolicy</PolicyIdReference>
</PolicySet>  

政策

<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"  PolicyId="ComplexPolicy" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides" 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">H1</AttributeValue>
               <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:environment:environment-id" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
            </Match>
         </AllOf>
      </AnyOf>
   </Target>
   <Rule Effect="Permit" RuleId="PermitForTestUser">
      <Condition>
         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
            <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">index.jsp</AttributeValue>
                  </Apply>
                  <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"></AttributeDesignator>
               </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">read</AttributeValue>
                     <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">view</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"></AttributeDesignator>
               </Apply>
            </Apply>
            <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-is-in">
               <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">testRole</AttributeValue>
               <AttributeDesignator AttributeId="http://wso2.org/claims/role" Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
            </Apply>
         </Apply>
      </Condition>
   </Rule>
</Policy>    

PolicySet 请求

<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">testU</AttributeValue>
    </Attribute>
</Attributes>
<Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment">
    <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:environment:environment-id" IncludeInResult="false">
        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">H1</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">index.jsp</AttributeValue>
    </Attribute>
</Attributes>

【问题讨论】:

    标签: wso2 wso2is rbac xacml xacml3


    【解决方案1】:

    如果您在 WSO2IS 中使用策略集,请注意以下事项。

    1. 您需要在 PDP 中发布策略集策略和参考策略。

    2. 然后您需要在 PDP 中启用策略集。您可以将参考政策保留为禁用政策。

    更多详情请参考here

    如果您打算使用 WSO2 身份服务器实现 RBAC 和 ABAC,我建议您通过 this 获得更多了解。

    【讨论】:

      【解决方案2】:

      我使用 Axiomatics Policy Server 测试了您的策略(见屏幕截图):

      然后我使用我们的模拟器测试了策略集:

      我收到了Indeterminate 作为回复。 Indeterminate 的根本原因是,Rule 中的 Condition 有一个名为 MustBePresent 的标志在 http://wso2.org/claims/role 属性上设置为 true,并且由于某种原因,评估未检索到任何值。

      WSO2 IS 似乎没有检索角色属性的值。您想在 WSO2 IS 中检查您的配置。或者,测试 Axiomatics Policy Server。

      HTH

      【讨论】:

      • 你好大卫,正如你所说“WSO2 IS 没有检索角色属性的值”,但在我的 wso2 日志中它向我显示这样的警告“{org.wso2.balana.PolicyReference} - PolicyReference已查询 id 为 ComplexPolicy 但未配置 PolicyFinder “但我已将策略和策略集上传到策略查找器。我不知道这是行不通的。大卫,你能不能给我一个 PolicySet 的例子,里面有关于 Wso2 上下文的 policyset 和 policySet 请求的策略参考??
      • 如果我在策略集中声明策略就可以了。但是如果我在策略集中传递策略的引用,那么它会给我类似“不适用”的错误,并且在控制台中它会在上面的评论中显示类似豪宅的警告。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-03
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 2016-12-04
      • 2019-03-02
      相关资源
      最近更新 更多