首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >包含XPath表达式的XACML策略在WSO2标识服务器5.0中发布时不起作用

包含XPath表达式的XACML策略在WSO2标识服务器5.0中发布时不起作用
EN

Stack Overflow用户
提问于 2014-07-03 07:51:44
回答 2查看 616关注 0票数 1

我尝试了http://www.webfarmr.eu/2011/08/xacml-102-xpath-and-xacml/中的第一个示例“在单个XACML请求中使用的XPath”部分。以防万一,这里是XACML策略:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?><xacml3:Policy xmlns:xacml3="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="xpath-target-single-req" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-overrides" Version="1">
  <xacml3:Description/>
<xacml3:PolicyDefaults><xacml3:XPathVersion>http://www.w3.org/TR/1999/REC-xpath-19991116</xacml3:XPathVersion></xacml3:PolicyDefaults>
  <xacml3:Target>
    <xacml3:AnyOf>
      <xacml3:AllOf>
        <xacml3:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
          <xacml3:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Gulliver's travels</xacml3:AttributeValue>
          <xacml3:AttributeSelector Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false" Path="/book/title/text()"/>
        </xacml3:Match>
        <xacml3:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:integer-greater-than">
          <xacml3:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer">18</xacml3:AttributeValue>
          <xacml3:AttributeDesignator AttributeId="age" Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" DataType="http://www.w3.org/2001/XMLSchema#integer" MustBePresent="false"/>
        </xacml3:Match>
      </xacml3:AllOf>
    </xacml3:AnyOf>
  </xacml3:Target>
  <xacml3:Rule Effect="Permit" RuleId="allow-read">
    <xacml3:Description/>
    <xacml3:Target/>
  </xacml3:Rule>
</xacml3:Policy>

当我使用策略管理页面中的"Try“选项并评估我的XACML请求时,响应返回许可决策。请注意,该策略尚未发布。

之后,我发布策略,启用它,并使用Tools->XACML菜单中的"Try“选项。结果是"NotApplicable“。

在“政策管理”或“政策视图”中,我没有任何其他政策。

包含XPath表达式的XACML策略是否需要其他配置?提供的场景有什么问题?

编辑:在日志中找到此消息:

代码语言:javascript
复制
[2014-07-03 11:13:25,021]  INFO {org.wso2.balana.finder.AttributeFinder} -  Failed to resolve any values for /book/title/text()
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-11-21 05:29:58

是。这是Identity Server中的一个bug。请参阅公共jira。然而,这并不是因为XPAth没有在Balana中实现,也不是Balana的问题。它与身份服务器相关,标识服务器没有正确初始化Balana引擎。

您甚至可以找到附加到公共jira的修补程序,并且可以尝试使用该修补程序。您可以从XPath找到有关身份服务器的这里示例的更多详细信息

票数 2
EN

Stack Overflow用户

发布于 2014-07-03 11:14:20

在编写示例时,我忽略了添加名称空间。您需要添加名称空间,然后它应该可以正常工作。例如,XACML策略变成:

代码语言:javascript
复制
<xacml3:Policy xmlns:xacml3="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="xpath-target-single-req" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-overrides">
<xacml3:PolicyDefaults><xacml3:XPathVersion>http://www.w3.org/TR/1999/REC-xpath-19991116</xacml3:XPathVersion></xacml3:PolicyDefaults>
     <xacml3:Target>
          <xacml3:AnyOf>
               <xacml3:AllOf>
                    <xacml3:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                         <xacml3:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Gulliver&apos;s travels</xacml3:AttributeValue>
                         <xacml3:AttributeSelector Path="/ns1:book/ns1:title/text()" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" xmlns:ns1="http://example.com"/>
                    </xacml3:Match>
                    <xacml3:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:integer-greater-than">
                         <xacml3:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer">18</xacml3:AttributeValue>
                         <xacml3:AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"  AttributeId="age" DataType="http://www.w3.org/2001/XMLSchema#integer" MustBePresent="false"/>
                    </xacml3:Match>
               </xacml3:AllOf>
          </xacml3:AnyOf>
     </xacml3:Target>
     <xacml3:Rule RuleId="allow-read" Effect="Permit">
          <xacml3:Target/>
     </xacml3:Rule>
</xacml3:Policy>

而XACML请求变成

代码语言:javascript
复制
<xacml-ctx:Request ReturnPolicyIdList="true" 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:1.0:subject-category:access-subject" >
      <xacml-ctx:Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" IncludeInResult="true">
         <xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Joe</xacml-ctx:AttributeValue>
      </xacml-ctx:Attribute>
      <xacml-ctx:Attribute AttributeId="age" IncludeInResult="true">
         <xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer">14</xacml-ctx:AttributeValue>
      </xacml-ctx:Attribute>
   </xacml-ctx:Attributes>
   <xacml-ctx:Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" >
      <xacml-ctx:Content><book xmlns="http://example.com">
<title>Gulliver's travels</title>
<isbn>xx-yy-zz</isbn>
<publisher>Axiomatics</publisher>
</book>      </xacml-ctx:Content>
   </xacml-ctx:Attributes>
   <xacml-ctx:Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment" >
   </xacml-ctx:Attributes>
   <xacml-ctx:Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" >
   </xacml-ctx:Attributes>
</xacml-ctx:Request>

注意,我添加了一个名称空间定义(ns1,http://example.com)。完全限定XPath表达式是很重要的。

如果它仍然对您不起作用,那么可能是Balana (WSO2IS)没有完全实现属性选择器。我在公理政策服务器上测试了它,它运行得很好。

大卫。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24548012

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档