我正在使用从git下载的巴拉娜。我正在研究一条策略规则,只有当策略的字符串包是请求中匹配属性的子集时,该规则才会允许。例如:请求包含属性"letter=a, letter=b",策略使用字符串子集来比较从请求到字符串包的一组字母属性。我尝试过子集的两个顺序(子集字符串包与子集字符串包字母),但是当我的测试请求应该是"Permit“时,它们都带着"Deny”返回。
样本政策
<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="policy1"
RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-overrides" Version="1.0">
<Target>
<AnyOf>
<AllOf>
<Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">
myguid0123456789
</AttributeValue>
<AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true" />
</Match>
</AllOf>
</AnyOf>
</Target>
<Rule Effect="Deny" RuleId="securityLevel">
<Condition>
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-greater-than">
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-one-and-only">
<AttributeDesignator AttributeId="securityLevel" Category="tags" DataType="http://www.w3.org/2001/XMLSchema#integer" MustBePresent="true" />
</Apply>
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer">
9000
</AttributeValue>
</Apply>
</Condition>
<AdviceExpressions>
<AdviceExpression AdviceId="channel-security-too-low" AppliesTo="Deny">
<AttributeAssignmentExpression AttributeId="urn:oasis:names:tc:xacml:2.0:example:attribute:text">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">
Message security is over 9000! It's not good cap'n, I cannae make it go any faster!
</AttributeValue>
</AttributeAssignmentExpression>
</AdviceExpression>
</AdviceExpressions>
</Rule>
<Rule Effect="Permit" RuleId="caveats">
<Condition>
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-subset">
<AttributeDesignator AttributeId="caveats" Category="tags" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true" />
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">
A
</AttributeValue>
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">
B
</AttributeValue>
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">
C
</AttributeValue>
</Apply>
</Apply>
</Condition>
<AdviceExpressions>
<AdviceExpression AdviceId="data-caveat-not-on-channel" AppliesTo="Deny">
<AttributeAssignmentExpression AttributeId="urn:oasis:names:tc:xacml:2.0:example:attribute:text">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">
caveat advice fail
</AttributeValue>
</AttributeAssignmentExpression>
</AdviceExpression>
</AdviceExpressions>
</Rule>
<Rule RuleId="permit-rule" Effect="Permit" />
</Policy>我要通过这个测试请求:
请求
<Request xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" CombinedDecision="false" ReturnPolicyIdList="true">
<Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action">
<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" IncludeInResult="true">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">
send
</AttributeValue>
</Attribute>
</Attributes>
<Attributes Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject">
<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" IncludeInResult="true">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">
99991699
</AttributeValue>
</Attribute>
</Attributes>
<Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" IncludeInResult="true">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">
myguid0123456789
</AttributeValue>
</Attribute>
</Attributes>
<Attributes Category="tags">
<Attribute AttributeId="securityLevel" IncludeInResult="true">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer">
8000
</AttributeValue>
</Attribute>
<Attribute AttributeId="caveats" IncludeInResult="true">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">
A
</AttributeValue>
</Attribute>
<Attribute AttributeId="caveats" IncludeInResult="true">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">
B
</AttributeValue>
</Attribute>
</Attributes>
</Request>所以,我的想法(因为我不确定有没有办法告诉它否定)是
如果这是真的,我的直觉是,一个匹配的子集,可以说“允许”,但如果它不能匹配条件,它将改为“拒绝”。
由于没有目标语句,我的直觉是,它“应该”尝试对所有请求计算该条件,因此不匹配条件不应导致规则跳过计算。
无论如何,看看样本,我想说“我的政策是A,B,但是你有A,B,C,所以我不得不拒绝你。”不幸的是,这不是它要做的,我也不知道为什么。请帮帮忙。x_x
发布于 2016-11-08 04:13:39
您的策略和要求中有几个问题。
首先,在XML和XACML中,<element>value</element>与
<element>
value
</element>如果您以这种方式发送请求,并且您的策略也是这样存储的,那么您正在检查的值是' A '、' B '等等。这将是一个问题。
其次,将算法与策略结合使用拒绝重写。P包含3个规则( R1、R2和R3 )。R1是一个拒绝规则。如果它适用,则返回拒绝,R2和R3将不予考虑。如果R1不适用,那么PDP将转到R2和R3。如果R2应用,那么可能的决定是允许的,但是PDP仍然需要检查R3,以防它返回一个拒绝。
如果securityLevel > 9000,您将被拒绝。
如果securityLevel <= 9000和警告最多包含A、B、C,您将获得许可证。
最后,R3总是授予您访问权限。因此,无论您在第二条规则中做了什么,第三条规则都会授予您访问权限。换句话说,R2根本不起任何作用。
我在公理化策略服务器中测试了您的策略,我可以在模拟器中看到这种行为。你应该和巴拉娜一样。
另外,您应该在目标中检查securityLevel,而不是在过度杀死的情况下。
它隐式地将条件下的负面匹配与效果的否定关联起来。
XACML中没有隐含的任何内容。许可证的反面是NotApplicable。
由于没有目标语句,我的直觉是,它“应该”尝试对所有请求计算该条件,因此不匹配条件不应导致规则跳过计算。
如果规则中没有目标,那么它就直接进入它所考虑的条件。它不会跳过这条规则。但在您的示例中,它返回NotApplicable。
如果你想达到你想要达到的目标,首先使用组合算法,然后将R3从许可改为拒绝。
有关更多信息,请查看此XACML博客。
https://stackoverflow.com/questions/40474395
复制相似问题