复杂的XACML,包的组合和依赖关系



我有一个这样的XACML请求(伪xacml(:

<Request>
<Attributes Category="resource">
<Attribute AttributeId="product">
<AttributeValue>A</AttributeValue>
</Attribute>
<Attribute AttributeId="market">
<AttributeValue>M2</AttributeValue>
<AttributeValue>M3</AttributeValue>
</Attribute>
<Attribute AttributeId="slice">
<AttributeValue>fus</AttributeValue>
<AttributeValue>do</AttributeValue>
<AttributeValue>rah</AttributeValue>
</Attribute>
</Attributes>

<Attributes Category="subject">
<Attribute AttributeId="product-market-slice-access">
<AttributeValue>A:::M2:::fus</AttributeValue>
<AttributeValue>A:::M2:::do</AttributeValue>
<AttributeValue>A:::M2:::rah</AttributeValue>
<AttributeValue>A:::M3:::fus</AttributeValue>
<AttributeValue>A:::M3:::do</AttributeValue>
<!--<AttributeValue>A:::M3:::rah</AttributeValue>--> <!-- Missing attribute, permission denied! -->
</Attribute>
</Attributes>
</Request>

我希望创建一个策略,拒绝上述请求的访问,并在主题被赋予缺少属性(注释掉(时允许访问。

有没有办法在XACML/ALFA策略中表达这一点?

如果XACML中有一个函数可以"连接"包(想想sql-join(,那将会有所帮助。这样我就可以使用函数"AnyOfAll"和"String-Equal"的组合。

所需函数的伪 xml:

<WantedFunction>
<Input>
<Separator>:::</Separator>
<Bag>
<AttributeValue>A</AttributeValue>
<AttributeValue>B</AttributeValue>
</Bag>
<Bag>
<AttributeValue>M2</AttributeValue>
<AttributeValue>M3</AttributeValue>
</Bag>
<Bag>
<AttributeValue>fus</AttributeValue>
<AttributeValue>do</AttributeValue>
<AttributeValue>rah</AttributeValue>
</Bag>
</Input>
<Output>
<Bag>
<AttributeValue>A:::M2:::fus</AttributeValue>
<AttributeValue>A:::M2:::do</AttributeValue>
<AttributeValue>A:::M2:::rah</AttributeValue>
<AttributeValue>A:::M3:::fus</AttributeValue>
<AttributeValue>A:::M3:::do</AttributeValue>
<AttributeValue>A:::M3:::rah</AttributeValue>
<AttributeValue>B:::M2:::fus</AttributeValue>
<AttributeValue>B:::M2:::do</AttributeValue>
<AttributeValue>B:::M2:::rah</AttributeValue>
<AttributeValue>B:::M3:::fus</AttributeValue>
<AttributeValue>B:::M3:::do</AttributeValue>
<AttributeValue>B:::M3:::rah</AttributeValue>
</Bag>
</Output>
</WantedFunction>

这是一个很好的问题,我很高兴看到你也在使用ALFA。让我对此作一些说明。

请求

首先,在 XACML 请求中,将属性作为两个单独的属性发送与将其作为单个属性发送相同。例如,以下两个请求是相同的。

同为员工的客户爱丽丝可以查看保险单 123 吗?

请求示例 1

<?xml version="1.0" encoding="UTF-8"?><xacml-ctx:Request ReturnPolicyIdList="true" CombinedDecision="false" xmlns:xacml-ctx="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
<xacml-ctx:Attributes Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" >
<xacml-ctx:Attribute AttributeId="com.axiomatics.user.type" IncludeInResult="true">
<xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">customer</xacml-ctx:AttributeValue>
</xacml-ctx:Attribute>
<xacml-ctx:Attribute AttributeId="com.axiomatics.user.type" IncludeInResult="true">
<xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">employee</xacml-ctx:AttributeValue>
</xacml-ctx:Attribute>
<xacml-ctx:Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" IncludeInResult="true">
<xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">alice</xacml-ctx:AttributeValue>
</xacml-ctx:Attribute>
</xacml-ctx:Attributes>
<xacml-ctx:Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" >
<xacml-ctx:Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" IncludeInResult="true">
<xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">view</xacml-ctx:AttributeValue>
</xacml-ctx:Attribute>
</xacml-ctx:Attributes>
<xacml-ctx:Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" >
<xacml-ctx:Attribute AttributeId="com.axiomatics.resource.type" IncludeInResult="true">
<xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">insurance policy</xacml-ctx:AttributeValue>
</xacml-ctx:Attribute>
<xacml-ctx:Attribute AttributeId="com.axiomatics.policy.polId" IncludeInResult="true">
<xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">123</xacml-ctx:AttributeValue>
</xacml-ctx:Attribute>
</xacml-ctx:Attributes>
</xacml-ctx:Request>

请求示例 2

<?xml version="1.0" encoding="UTF-8"?><xacml-ctx:Request ReturnPolicyIdList="true" CombinedDecision="false" xmlns:xacml-ctx="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
<xacml-ctx:Attributes Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" >
<xacml-ctx:Attribute AttributeId="com.axiomatics.user.type" IncludeInResult="true">
<xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">customer</xacml-ctx:AttributeValue>
<xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">employee</xacml-ctx:AttributeValue>
</xacml-ctx:Attribute>
<xacml-ctx:Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" IncludeInResult="true">
<xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">alice</xacml-ctx:AttributeValue>
</xacml-ctx:Attribute>
</xacml-ctx:Attributes>
<xacml-ctx:Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" >
<xacml-ctx:Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" IncludeInResult="true">
<xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">view</xacml-ctx:AttributeValue>
</xacml-ctx:Attribute>
</xacml-ctx:Attributes>
<xacml-ctx:Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" >
<xacml-ctx:Attribute AttributeId="com.axiomatics.resource.type" IncludeInResult="true">
<xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">insurance policy</xacml-ctx:AttributeValue>
</xacml-ctx:Attribute>
<xacml-ctx:Attribute AttributeId="com.axiomatics.policy.polId" IncludeInResult="true">
<xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">123</xacml-ctx:AttributeValue>
</xacml-ctx:Attribute>
</xacml-ctx:Attributes>
</xacml-ctx:Request>

属性是袋子

在 XACML 中,属性始终是包。它始终是多值的,即使它包含零个或一个值。这意味着,如果你想对属性进行操作,你需要记住它是一个袋子。例如,如果你想将 market 与 slice 连接起来,你必须将其转换为单个值(并且只有在它确实是单个值时才有效(或使用高阶函数。高阶函数是将另一个函数作为参数的函数,例如 AllOf。

连接多值属性

一种选择是使用字符串连接,但该函数仅对原子值进行操作。您可以使用 map 将其应用于袋子,但不幸的是,在您的情况下,您需要一张能够在多个袋子上工作的地图。

解决方案:使用多个决策请求

您可以使用多决策配置文件 (MDP(,而不是在一个批量请求中发送所有值,它允许您一次性发送多个请求,例如:

爱丽丝可以查看、编辑、删除记录 1、2、3 吗?

答案将包含与组合乘积一样多的决策(在本例中为 1x3x3(。

在您的情况下,您可以将所有决策合并为一个决策。如果所有允许,则允许否则拒绝。MDP 中有一个参数可以执行此操作。它被称为CombinedDecision。

考虑到这一点,以下是策略的外观(使用 ALFA 表示法(:

namespace com.axiomatics{
attribute product{
category = resourceCat
id = "product"
type = string
}
attribute market{
category = resourceCat
id = "market"
type = string
}
attribute slice{
category = resourceCat
id = "slice"
type = string
}
attribute productMarketSliceAccess{
category = subjectCat
id = "product-market-slice-access"
type = string
}
policy userAccessProductMarketSlice{
apply firstApplicable
rule allowAccess{
permit
condition stringIsIn(stringOneAndOnly(product)+
stringOneAndOnly(market)+
stringOneAndOnly(slice),productMarketSliceAccess)
}
}
}

样品请求 - MDP

{
"Request": {
"CombinedDecision": true,
"AccessSubject": {
"Attribute": [
{
"AttributeId": "product-market-slice-access",
"Value": "BAC"
},
{
"AttributeId": "product-market-slice-access",
"Value": "DEF"
}
]
},
"Resource": [{
"Attribute": [
{
"AttributeId": "market",
"Value": "A"
},
{
"AttributeId": "product",
"Value": "B"
},
{
"AttributeId": "slice",
"Value": "C"
}
]
},{
"Attribute": [
{
"AttributeId": "market",
"Value": "E"
},
{
"AttributeId": "product",
"Value": "D"
},
{
"AttributeId": "slice",
"Value": "F"
}
]
}],
"Action": {
"Attribute": []
},
"Environment": {
"Attribute": []
}
}
}

最新更新