【问题标题】:WSO2 Identity Server XACML Policies with XPathVersion being XPath 2.0XPathVersion 为 XPath 2.0 的 WSO2 身份服务器 XACML 策略
【发布时间】:2013-12-13 21:37:17
【问题描述】:

我编写了一个使用 XPath 2.0 功能的策略(包含在下面),用于 WSO2 身份服务器。我已经在 XPathVersion 元素中指定了正确的值,但我仍然收到指向 XPath 表达式没有被评估为 XPath 2.0 的错误。

我很确定 WSO2 身份服务器没有使用 XPathVersion 元素的值,因为当我将其更改为无效的值(例如“this-is-not-a-valid-xpath-version”)时不会抱怨,仍然会计算 XPath 表达式(尽管是 XPath 1.0。)

我的政策:

<Policy PolicyId="application-dashu" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-overrides" Version="1.0" xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
  <PolicyDefaults>
    <XPathVersion>http://www.w3.org/TR/2007/REC-xpath20-20070123</XPathVersion>
  </PolicyDefaults>
  <Target>
    <AnyOf>
      <AllOf>
        <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:anyURI-equal">
          <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">urn:siphon-io:schema:application:dashu</AttributeValue>
          <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:resource:target-namespace" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" DataType="http://www.w3.org/2001/XMLSchema#anyURI" MustBePresent="true"/>
        </Match>
      </AllOf>
    </AnyOf>
  </Target>
  <Rule Effect="Permit" RuleId="permit-index">
    <Condition>
      <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: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>
          <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">index</AttributeValue>
        </Apply>
        <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-subset">
          <AttributeSelector
            MustBePresent="false"
            Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
            Path="/*[namespace-uri()='urn:siphon-io:schema:application:dashu' and local-name()='Instance']/*[namespace-uri()='urn:siphon-io:schema:application:dashu' and local-name()='Tag']/concat('{', attribute::Name, '}', text())"
            DataType="http://www.w3.org/2001/XMLSchema#string"
            />
          <AttributeSelector
            MustBePresent="false"
            Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
            Path="/*[namespace-uri()='urn:oasis:names:tc:SAML:2.0:assertion' and local-name()='Assertion']/*[namespace-uri()='urn:oasis:names:tc:SAML:2.0:assertion' and local-name()='AttributeStatement']/*[namespace-uri()='urn:oasis:names:tc:SAML:2.0:assertion' and local-name()='Attribute']/*[namespace-uri()='urn:oasis:names:tc:SAML:2.0:assertion' and local-name()='AttributeValue']/concat('{', parent::node()/attribute::Name, '}', text())"
            DataType="http://www.w3.org/2001/XMLSchema#string"
            />
        </Apply>
      </Apply>
    </Condition>
  </Rule>
</Policy>

我的要求:

<p0:Request CombinedDecision="false" ReturnPolicyIdList="false" xmlns:p0="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
  <p0:Attributes Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject">
    <p0:Content>
      <saml:Assertion ID="_u5Ik0MW0G5jNlnFsYG6DGvl7j0WEmBJR" IssueInstant="2013-12-12T23:11:02.354Z" Version="2.0" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
        <saml:Issuer>urn:movingdata.auth0.com</saml:Issuer>
        <saml:Subject>
          <saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">auth0|b939821bd143c2d075e2feaf0220b6ed09212cc9</saml:NameID>
          <saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
            <saml:SubjectConfirmationData InResponseTo="request-1386889754280-nusav-zotop-rizul" NotOnOrAfter="2013-12-13T00:11:02.354Z" Recipient="http://dashboard.dbsu.com/auth/saml2/sso/post"/>
          </saml:SubjectConfirmation>
        </saml:Subject>
        <saml:Conditions NotBefore="2013-12-12T23:11:02.354Z" NotOnOrAfter="2013-12-13T00:11:02.354Z">
          <saml:AudienceRestriction/>
        </saml:Conditions>
        <saml:AttributeStatement>
          <saml:Attribute Name="urn:siphon-io:customer:dbsu:project">
            <saml:AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:anyType">99-101</saml:AttributeValue>
          </saml:Attribute>
          <saml:Attribute Name="urn:siphon-io:customer:dbsu:project">
            <saml:AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:anyType">99-102</saml:AttributeValue>
          </saml:Attribute>
          <saml:Attribute Name="urn:siphon-io:customer:dbsu:project">
            <saml:AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:anyType">99-103</saml:AttributeValue>
          </saml:Attribute>
        </saml:AttributeStatement>
        <saml:AuthnStatement AuthnInstant="2013-12-12T23:11:02.354Z">
          <saml:AuthnContext>
            <saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified</saml:AuthnContextClassRef>
          </saml:AuthnContext>
        </saml:AuthnStatement>
      </saml:Assertion>
    </p0:Content>
  </p0:Attributes>
  <p0:Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
    <p0:Content>
      <p1:Instance xmlns:p1="urn:siphon-io:schema:application:dashu" Host="dashboard.dbsu.com" ID="81ffe0de0ab298abf33f582e3909b9c6de1f7e97">
        <p1:Tag Name="urn:siphon-io:customer:dbsu:project">99-101</p1:Tag>
      </p1:Instance>
    </p0:Content>
    <p0:Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:resource:target-namespace" IncludeInResult="false">
      <p0:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">urn:siphon-io:schema:application:dashu</p0:AttributeValue>
    </p0:Attribute>
  </p0:Attributes>
  <p0:Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action">
    <p0:Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" IncludeInResult="false">
      <p0:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">index</p0:AttributeValue>
    </p0:Attribute>
  </p0:Attributes>
</p0:Request>

【问题讨论】:

    标签: xpath wso2 wso2is xacml


    【解决方案1】:

    WSO2 Identity Server 附带 xalan 2.7.1(可在 /lib/endorsed 中找到)并且 xalan 2.7.1 不支持 XPath 2.0。因此 Identity Server 将不支持 Xpath 2.0。这对于 Identity Server 来说是众所周知的。我想,我们可以从发行版中删除 xalan 2.7.1 并使用诸如撒克逊语之类的东西。 (我没有尝试过)。我想,它很快就会在未来的版本中完成。但是,我使用最新版本 4.5.0 尝试了您的政策和请求。但是“concat”函数存在一些问题,可能是由于您提到的 XPath 2.0 问题。一旦我删除“concat”,它就会按预期工作。以下是我修改的政策,它会根据您给出的请求将预期结果返回为“允许”。

    <Policy PolicyId="application-dashu" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-overrides" Version="1.0" xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
      <PolicyDefaults>
        <XPathVersion>http://www.w3.org/TR/2007/REC-xpath20-20070123</XPathVersion>
      </PolicyDefaults>
      <Target>
        <AnyOf>
          <AllOf>
            <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:anyURI-equal">
              <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">urn:siphon-io:schema:application:dashu</AttributeValue>
              <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:resource:target-namespace" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" DataType="http://www.w3.org/2001/XMLSchema#anyURI" MustBePresent="true"/>
            </Match>
          </AllOf>
        </AnyOf>
      </Target>
      <Rule Effect="Permit" RuleId="permit-index">
        <Condition>
          <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: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>
              <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">index</AttributeValue>
            </Apply>
            <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-subset">
              <AttributeSelector
                MustBePresent="false"
                Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
                Path="/*[namespace-uri()='urn:siphon-io:schema:application:dashu' and local-name()='Instance']/*[namespace-uri()='urn:siphon-io:schema:application:dashu' and local-name()='Tag']/text()"
                DataType="http://www.w3.org/2001/XMLSchema#string"
                />
              <AttributeSelector
                MustBePresent="false"
                Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
                Path="/*[namespace-uri()='urn:oasis:names:tc:SAML:2.0:assertion' and local-name()='Assertion']/*[namespace-uri()='urn:oasis:names:tc:SAML:2.0:assertion' and local-name()='AttributeStatement']/*[namespace-uri()='urn:oasis:names:tc:SAML:2.0:assertion' and local-name()='Attribute']/*[namespace-uri()='urn:oasis:names:tc:SAML:2.0:assertion' and local-name()='AttributeValue']/text()"
                DataType="http://www.w3.org/2001/XMLSchema#string"
                />
            </Apply>
          </Apply>
        </Condition>
      </Rule>
    </Policy>
    

    【讨论】:

    • 是的,这基本上就是我目前所拥有的。问题是它没有考虑 SAML 属性或实例标签的名称,我使用这些名称来促进对用户配置文件和应用程序实例的委派管理。我想答案只是“是的,那行不通。”
    猜你喜欢
    • 1970-01-01
    • 2018-03-07
    • 1970-01-01
    • 2012-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多