代码之家  ›  专栏  ›  技术社区  ›  Claude Falbriard

WSO2标识/标准编辑器的XACML评估/是否有可用的调试功能?

  •  0
  • Claude Falbriard  · 技术社区  · 9 年前

    很难从WSO2XACML标准编辑器制定的策略定义中解释“Try It”结果数据。

    有关XACML引擎处理和定义的问题:

    • 是否有显示部分结果的调试支持 从每个规则和语句评估?
    • 布尔逻辑是否适用于“或”、“和”组合?
    • 是否有工具可用于修改默认属性值(字符串),例如使用“当前时间”属性作为有效的环境设置?

    策略(由标准编辑器键入)

    <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="TodaysPolicy1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides" Version="1.0">
       <Description>Standard Editor Doctor Rule                        </Description>
       <Target>
          <AnyOf>
             <AllOf>
                <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
                   <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">^(http:)</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"/>
                </Match>
             </AllOf>
          </AnyOf>
       </Target>
       <Rule Effect="Permit" RuleId="DoctorAdmin">
          <Target>
             <AnyOf>
                <AllOf>
                   <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
                      <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">^(http:)</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"/>
                   </Match>
                </AllOf>
             </AnyOf>
          </Target>
          <Condition>
             <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:or">
                <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
                   <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                      <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
                         <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>
                      <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">admin</AttributeValue>
                   </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">write</AttributeValue>
                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">update</AttributeValue>
                         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">delete</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:not">
                      <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
                         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-greater-than">
                            <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
                               <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"/>
                            </Apply>
                            <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">07:00:00 05:00</AttributeValue>
                         </Apply>
                         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-less-than">
                            <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
                               <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"/>
                            </Apply>
                            <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">20:00:00 05:00</AttributeValue>
                         </Apply>
                      </Apply>
                   </Apply>
                </Apply>
                <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                   <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
                      <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>
                   <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">doctor</AttributeValue>
                </Apply>
             </Apply>
          </Condition>
       </Rule>
    </Policy> 
    

    请求(由Try It生成)

                         <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">doctor</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">08:00:00 05:00</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">http://localhost:9444/medicalrecords</AttributeValue>
    </Attribute>
    </Attributes>
    </Request>
    

    通过[测试评估]的结果

                         <Response xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
    <Result>
    <Decision>NotApplicable</Decision>
    <Status>
    <StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:ok"/>
    </Status>
    </Result>
    </Response>   
    

    提前感谢您的指导。

    1 回复  |  直到 3 年前
        1
  •  0
  •   David Brossard    9 年前

    WSO2中确实缺少调试功能。我使用Axiomatics策略管理点及其ALFA插件编写并测试所有策略。

    我在人民行动党内部尝试过你的政策。这是在PAP内部展开时的样子。

    Exploring a policy with the Axiomatics Policy Administration Point

    现在我也检查了您的XACML请求。

    a XACML 3.0 request inside the Axiomatics PAP

    你的政策行不通的主要原因之一。

    • 策略需要一个资源id,但您的请求会发送一个环境id。

    也就是说,您的政策还有其他问题:

    • 首先,在资源id上使用字符串regexp匹配,但实际上应该使用字符串开头,因为您要做的是检查字符串是否以http://开头。您还希望使anyURI类型不是字符串。
    • 其次,您要检查两次:一次在策略中,一次在规则中。一次就够了,而不是两次。
    • 第三,将受试者id与医生进行比较。医生是一个角色,而不是主题id,因此请为此创建一个属性
    • 当XACML中有一个名为urn:oasis:names:tc:XACML:1.0:environment:currenttime的属性时,您可以使用environment-id来传递当前时间。
    • 你用条件来表达你可以在目标中轻易表达的东西。
    • 最后,你在条件中加入了太多的逻辑,例如,你可以在4个规则中拆分出4个不同的动作。