xml - Authzforce - 简单 ABAC 策略创建失败
问题描述
我正在使用Authzforce 8.1.0
并且已经根据用户和程序员指南RBAC
中给出的示例创建了几个策略场景,但我想创建一个简单的场景。ABAC
作为 XACML 语言的新手,我正在尝试从这里学习一些示例。更具体地说,我正在尝试实施类似于4.1.1 Example policy的策略。
我要创建的政策
假设一家名为 Medi Corp 的公司(由其域名:med.example.com 标识)有一个访问控制策略,该策略用英语声明:
任何在“med.example.com”命名空间中具有电子邮件名称的用户都可以对任何资源执行任何操作。
<?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
我收到以下错误
错误
<?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>
块,因此我认为这可能是一个问题,并尝试将策略包含在 apolicySet
中,如下所示:
<?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>
但现在我得到以下信息:
回复
<?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 请求的正确格式是什么?对此政策访问请求的示例也将不胜感激,在此先感谢!
解决方案
不幸的是,第 4.1.1 节中的这个示例存在已知问题,其中一些我已在xacml-comment 邮件列表中报告。它应该在 XACML 规范的下一个版本中得到修复。同时,您需要解决这些问题:
- 完全删除
xsi:schemaLocation
。因为位置http://docs.oasis-open.org/xacml/FIXME.xsd
是错误的,并且 AuthzForce 已经为 XACML 模式使用了自己的位置。 - RuleCombiningAlgId
identifier:rule-combining-algorithm:deny-overrides
是错误的。替换为urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-overrides
。
我还确认 AuthzForce Server 的 REST API 仅接受 PolicySets 作为/pap/policies
端点上的输入,因此您必须像您一样将您的 Policy 包装在 PolicySet 中。urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:only-one-applicable
但是,如果您希望 PolicySet 的结果与 Policy 等效,则应将 PolicyCombiningAlgId 更改为。
--编辑2020-04-06--
所以固定的 PolicySet 是这样的:
<?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>
推荐阅读
- node.js - 从NodeJS将数组插入redis
- google-apps-script - 通过谷歌应用脚本将谷歌云搜索集成到 gmail 插件中
- php - 在 PHP 中读取/下载大文件而不会耗尽内存
- firebase - nuxt 上的 Firebase 身份验证侦听器
- android - 问题 OpenSSL library not found 为 android ABI 构建 PJSIP 项目
- android - Align Textview drawable and text to baseline bottom?
- xml - 使用 XSLT 获取字符串在数组中的位置
- r - 如何在字符串中找到相同的模式?
- python - 使用 jpype 在 Python 中启动 JVM 的困难
- angular - 如何在角度 4 中修复“无法将'new'与类型缺少调用或构造签名的表达式一起使用”?