【问题标题】:What does a HTTP 409 mean when adding a new XACML request to Authzforce向 Authzforce 添加新的 XACML 请求时,HTTP 409 是什么意思
【发布时间】:2019-12-02 08:23:23
【问题描述】:

我正在测试 Authzforce Server 应用程序以输入 XACML 策略并测试 XACML 决策请求。我正在尝试输入我的第一个 XACML 策略集。问题是我总是得到一个没有响应正文的 409 Conflict 响应,尽管当我按 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 响应,没有关于实际冲突的详细信息,但是当我尝试使用...检索策略时...

GET /domains/domain-id/pap/policies/PolicySetExample/1.0

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

<?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 的默认“根”策略集有冲突?

谢谢, 安德拉斯

【问题讨论】:

    标签: authorization access-control xacml abac authzforce


    【解决方案1】:

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

    2 个选项:

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

    【讨论】:

    • 感谢您的回复。问题是我在第一次尝试时也得到了 409,但无论如何都保存了该政策。事实证明,该解决方案与您在第 45 期中建议的解决方案相同:github.com/authzforce/server/issues/45。我将策略组合算法值更新为 urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:deny-overrides 和 urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-覆盖并接受策略集。
    猜你喜欢
    • 2020-04-11
    • 2014-03-28
    • 1970-01-01
    • 1970-01-01
    • 2016-03-30
    • 1970-01-01
    • 2016-03-12
    • 2013-06-27
    相关资源
    最近更新 更多