首页 > 解决方案 > XACML 阅读资源

问题描述

我正在尝试制定一个规则,该规则仅在为每个用户读取操作时才允许访问任何资源。我怀疑我是否需要在这里放置像任何用户这样的东西

<Rule Effect="Permit" RuleId="Rule Permit #1">
    <Target>
        <AnyOf>
            <AllOf>
                <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
                    <AttributeValue 
                        DataType="http://www.w3.org/2001/XMLSchema#string">any
                    </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">
                    </AttributeDesignator>
                </Match>

然后动作

 <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                    <AttributeValue 
                         DataType="http://www.w3.org/2001/XMLSchema#string">read
                    </AttributeValue>
                    <AttributeDesignator 
                        AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" 
                        Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" 
                        DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
                </Match>

或者我可以删除第一部分并直接执行操作,因为资源是任意的。

谢谢!!

标签: xacml

解决方案


您只需要匹配操作:

<Rule Effect="Permit" RuleId="Rule Permit #1">
  <Target>
    <AnyOf>
        <AllOf>
            <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                <AttributeValue 
                  DataType="http://www.w3.org/2001/XMLSchema#string">read</AttributeValue>
                <AttributeDesignator 
                  AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id"  
                  Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" 
                  DataType="http://www.w3.org/2001/XMLSchema#string" 
                  MustBePresent="true" />
            </Match>
        </AllOf>
    </AnyOf>
  </Target>
</Rule>

在这种情况下,当且仅当 action-id 等于“读取”时,规则评估为 Permit,而不管用户或资源属性如何,换句话说:对于任何用户或资源。请注意,最终决定取决于封闭策略上的规则组合算法(如果有,可能还有 PolicySet 上的策略组合算法)。如果你得到不同的东西,那就是 XACML 实现的问题。


推荐阅读