首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Authzforce -简单的ABAC策略创建失败

Authzforce -简单的ABAC策略创建失败
EN

Stack Overflow用户
提问于 2020-04-03 10:35:00
回答 1查看 172关注 0票数 1

我正在使用Authzforce 8.1.0,并且我已经根据用户和程序员中给出的示例创建了几个RBAC策略场景,但是我想创建一个简单的ABAC场景。

作为XACML语言的新手,我正在尝试学习这里中的一些示例。更具体地说,我试图实现一个类似于4.1.1示例策略的策略。

策略我想要创建

假设一个名为Medi公司的公司(其域名为: med.example.com)拥有一个访问控制策略,该策略以英文声明: 任何在"med.example.com“命名空间中具有电子邮件名称的用户都可以对任何资源执行任何操作。

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
   <Policy xmlns="urn:oasis:names:tc:xacml:3.0:schema:os"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="urn:oasis:names:tc:xacml:3.0:schema:os
           http://docs.oasis-open.org/xacml/FIXME.xsd"
           PolicyId="urn:oasis:names:tc:xacml:3.0:example:SimplePolicy1"
           Version="1.0"
           RuleCombiningAlgId="identifier:rule-combining-algorithm:deny-overrides">
     <Description>
       Medi Corp access control policy
     </Description>
     <Target/>
      <Rule
       RuleId= "urn:oasis:names:tc:xacml:3.0:example:SimpleRule1"
       Effect="Permit">
       <Description>
         Any subject with an e-mail name in the med.example.com domain
         can perform any action on any resource.
       </Description>
       <Target>
         <AnyOf>
           <AllOf>
             <Match
               MatchId="urn:oasis:names:tc:xacml:1.0:function:rfc822Name-match">
                <AttributeValue  DataType="http://www.w3.org/2001/XMLSchema#string">med.example.com</AttributeValue>
                <AttributeDesignator
                    Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
                    AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id"
                    DataType="urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name"/>
                </Match>
           </AllOf>
         </AnyOf>
       </Target>
      </Rule>
    </Policy>

当我试图在POST{ip}:{port}/authzforce-ce/domains/{domainId}/pap/policies这个策略时,我得到了以下错误

误差

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error xmlns:ns2="http://authzforce.github.io/core/xmlns/pdp/6.0">
<message>Invalid parameters: cvc-elt.1: Cannot find the declaration of element 'Policy'.</message>
</error>

到目前为止,我在authzforce中看到的所有示例都是从一个<PolicySet>声明开始的(在这个声明中,我们可以声明多个<Policy>块,因此我认为这可能是一个问题,并试图将策略包含在policySet中,如下所示:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PolicySet
 xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
 PolicySetId="first_policyset_id"
 Version="1.0"
 PolicyCombiningAlgId="urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:permit-unless-deny">
 <Description>Policy for Github</Description>
 <Target />
 <Policy
   PolicyId="urn:oasis:names:tc:xacml:3.0:example:SimplePolicy1"
           Version="1.0"
           RuleCombiningAlgId="identifier:rule-combining-algorithm:deny-overrides">
  <Description>
       Medi Corp access control policy
     </Description>
     <Target/>
      <Rule
       RuleId= "urn:oasis:names:tc:xacml:3.0:example:SimpleRule1"
       Effect="Permit">
       <Description>
         Any subject with an e-mail name in the med.example.com domain
         can perform any action on any resource.
       </Description>
       <Target>
         <AnyOf>
           <AllOf>
             <Match
               MatchId="urn:oasis:names:tc:xacml:1.0:function:rfc822Name-match">
                <AttributeValue  DataType="http://www.w3.org/2001/XMLSchema#string">med.example.com</AttributeValue>
                <AttributeDesignator
                    Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
                    AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id"
                    MustBePresent="false"
                    DataType="urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name"/>
                </Match>
           </AllOf>
         </AnyOf>
       </Target>
      </Rule>
    </Policy>
</PolicySet>

但现在我得到了以下信息:

响应

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error xmlns:ns2="http://authzforce.github.io/core/xmlns/pdp/6.0">
    <message>Failed to find a root PolicySet with id = 'first_policyset_id', Version=1.0,EarliestVersion=*,LatestVersion=*: Matched PolicySet 'first_policyset_id' (version 1.0) is invalid or its content is unavailable</message>
</error>

提出这样一个简单的ABAC策略场景的XACML请求的正确格式是哪种?有关策略访问请求的示例也将非常感谢,谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-04-04 18:10:21

这个来自4.1.1节的例子不幸地知道了一些问题,其中一些是我在xacml-评论邮件列表上报告的。应该在XACML规范的下一个版本中修复它。同时,你需要修复这些:

  1. 完全删除xsi:schemaLocation。因为位置http://docs.oasis-open.org/xacml/FIXME.xsd是错误的,AuthzForce已经为XACML模式使用了自己的位置。
  2. RuleCombiningAlgId identifier:rule-combining-algorithm:deny-overrides错了。用urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-overrides代替。

我还确认了AuthzForce服务器的REST只接受PolicySets作为/pap/policies端点的输入,所以您必须像以前一样将策略包装在PolicySet中。但是,如果希望PolicyCombiningAlgId的结果与策略等效,则应该将PolicySet更改为urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:only-one-applicable

-编辑2020-04-06--

所以固定的PolicySet是这样的:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PolicySet 
 xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
 PolicySetId="PolicySet_1"
 Version="1.0"
 PolicyCombiningAlgId="urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:only-one-applicable">
 <Description>Sample PolicySet</Description>
 <Target />
 <Policy 
  PolicyId="urn:oasis:names:tc:xacml:3.0:example:SimplePolicy1"
  Version="1.0"
  RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-overrides">
  <Description>Medi Corp access control policy</Description>
  <Target/>
  <Rule
   RuleId= "urn:oasis:names:tc:xacml:3.0:example:SimpleRule1"
   Effect="Permit">
   <Description>Any subject with an e-mail name in the med.example.com domain can perform any action on any resource.</Description>
   <Target>
     <AnyOf>
       <AllOf>
         <Match
          MatchId="urn:oasis:names:tc:xacml:1.0:function:rfc822Name-match">
          <AttributeValue  DataType="http://www.w3.org/2001/XMLSchema#string">med.example.com</AttributeValue>
          <AttributeDesignator
           Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
           AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id"
           DataType="urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name"
           MustBePresent="true"/>
         </Match>
       </AllOf>
     </AnyOf>
   </Target>
  </Rule>
 </Policy>
</PolicySet>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61009964

复制
相关文章

相似问题

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