1

我正在测试 Authzforce Server 应用程序以输入 XACML 策略并测试 XACML 决策请求。我正在尝试输入我的第一个 XACML 策略集。问题是我总是得到一个没有响应正文的 409 冲突响应,尽管当我通过 ID 和版本检索策略集时,它显然已成功保存在数据存储中。

这是我输入的策略集:

<PolicySet xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicySetId="PolicySetExample" Version="1.0" PolicyCombiningAlgId="identifier:policy-combining-algorithm:deny-overrides">
 <Target/>
  <Policy PolicyId="urn:oasis:names:tc:xacml:3.0:example:SimplePolicy1" Version="1.0" RuleCombiningAlgId="identifier:rule-combining-algorithm:deny-overrides">
   <Target/>
   <Rule RuleId="urn:oasis:names:tc:xacml:3.0:example:MyRule" Effect="Permit">
     <Target>
      <AnyOf>
       <AllOf>
         <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
          <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Medical record</AttributeValue> 
            <AttributeDesignator MustBePresent="false" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string"/>
         </Match>
         <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
          <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Doctor</AttributeValue>
            <AttributeDesignator MustBePresent="false" Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id-qualifier" DataType="http://www.w3.org/2001/XMLSchema#string"/>
         </Match>
        </AllOf>
       </AnyOf>
     </Target>
     <Condition>
       <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 MustBePresent="false" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string"/>
        </Apply>
       <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">write</AttributeValue>
      </Apply>
     </Condition>
    </Rule>
   </Policy>
</PolicySet>

...使用服务端点 POST /domains/domain-id/pap/policies。该服务以 409 响应,没有关于实际冲突的详细信息,但是当我尝试使用...检索策略时

获取 /domains/domain-id/pap/policies/PolicySetExample/1.0

...然后我看到策略集已保存,我得到策略集文档,其中包含对名为“ComplexPolicy”的策略的策略 ID 引用:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns4:PolicySet xmlns="http://authzforce.github.io/core/xmlns/pdp/6.0" xmlns:ns2="http://authzforce.github.io/rest-api-model/xmlns/authz/5" xmlns:ns3="http://authzforce.github.io/pap-dao-flat-file/xmlns/properties/3.6" xmlns:ns4="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" xmlns:ns5="http://www.w3.org/2005/Atom" PolicySetId="PolicySetExample" Version="1.0" PolicyCombiningAlgId="urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:permit-overrides">
    <ns4:Description>TestPolicySet</ns4:Description>
    <ns4:Target>
        <ns4:AnyOf>
            <ns4:AllOf>
                <ns4:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                    <ns4:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">H1</ns4:AttributeValue>
                    <ns4:AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment" AttributeId="urn:oasis:names:tc:xacml:1.0:environment:environment-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"/>
                </ns4:Match>
            </ns4:AllOf>
        </ns4:AnyOf>
    </ns4:Target>
    <ns4:PolicyIdReference>ComplexPolicy</ns4:PolicyIdReference>
</ns4:PolicySet>

我已经检查了 /var/log/tomcat8/authzforce-ce/error.log 中的 Authzforce 日志文件,但与此特定错误无关。

欢迎任何想法和指点。

编辑:是否与Authzforce的默认“root”策略集发生冲突?

谢谢, 安德拉斯

4

1 回答 1

1

据我了解,您已经在版本“1.0”中成功发布了PolicySet 'PolicySetExample',因为这是您使用GET .../PolicySetExample/1.0. 现在,您尝试再次在版本“1.0”中发布 PolicySet“PolicySetExample”(但新内容),但由于 REST API 将其解释为尝试创建具有相同 PolicySetId 和版本的新 PolicySet(PolicySet 资源)而失败,而(PolicySetId,Version)元组在域上应该是唯一的。所以在你的情况下,它可能是一个Version冲突

2个选项:

  1. 如果要替换/覆盖之前的 PolicySet 内容,.../PolicySetExample/1.0请使用 DELETE 方法删除服务器上现有的内容,然后使用 POST 方法再次上传/创建 PolicySet。
  2. 如果要上传新版本(并将旧版本保留在服务器上),请增加 Version 属性。请注意:a)您可以拥有多个版本的 PolicySet(具有相同的 PolicySetId 但我的意思是不同的版本);b) 如果您在 PolicySetIdReference 中使用它,则在 AuthzForce 中默认使用最新版本,除非您明确指定版本(或根据 XACML 标准使用 EarliestVersion/LatestVersion,但我不建议使用它们)。
于 2019-07-24T23:56:27.510 回答