XACML资源

时间:2013-02-26 21:56:03

标签: logic xacml2

我正在尝试编写一个代码,使用户能够根据安全角色访问网站内容。因此,一些用户可以看到所有内容,有些用户只能看到具有特定扩展名的网址。

我的大多数代码都可以使用,但是我无法访问3个子类别。

<Rule Effect="Permit" RuleId="accesses">
    <Description>Permission for lower clearance</Description>
    <Target>
        <Resources>
            <Resource>
                <ResourceMatch
                    MatchId="urn:oasis:names:tc:xacml:1.0:function:regexp-string-match">
                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">home.html
                    </AttributeValue>
                    <ResourceAttributeDesignator
                        AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id"
                        DataType="http://www.w3.org/2001/XMLSchema#string" Issuer="policy-admin@website.com"
                        MustBePresent="true" />
                </ResourceMatch>
            </Resource>
            <Resource>
                <ResourceMatch
                    MatchId="urn:oasis:names:tc:xacml:1.0:function:regexp-string-match">
                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">localweather.html
                    </AttributeValue>
                    <ResourceAttributeDesignator
                        AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id"
                        DataType="http://www.w3.org/2001/XMLSchema#string" Issuer="policy-admin@website.com"
                        MustBePresent="true" />
                </ResourceMatch>
            </Resource>
            <Resource>
                <ResourceMatch
                    MatchId="urn:oasis:names:tc:xacml:1.0:function:regexp-string-match">
                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">about.html
                    </AttributeValue>
                    <ResourceAttributeDesignator
                        AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id"
                        DataType="http://www.w3.org/2001/XMLSchema#string" Issuer="policy-admin@website.com"
                        MustBePresent="true" />
                </ResourceMatch>
            </Resource>
        </Resources>
    </Target>
    <Condition>
        <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:regexp-string-match">
            <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
                <SubjectAttributeDesignator AttributeId="AccessLevel"
                    DataType="http://www.w3.org/2001/XMLSchema#string" Issuer="policy-admin@website.com"
                    MustBePresent="true" />
                <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Clear</AttributeValue>
            </Apply>
        </Apply>
    </ Condition >
</Rule>

我有这3个资源,当我运行程序时,我得到一个“不确定”的响应。我可以每条规则只有1个资源吗?是其他东西抛出异常吗?

2 个答案:

答案 0 :(得分:0)

您可以在目标中拥有树资源。根据你的规则,他们将充当“或”。请检查您的XACML请求,可能是您发送的请求与策略不匹配(策略有MustBePresent =“true表示,如果属性不存在,PDP会产生不确定的错误)。请将它们更改为”false“并看到。

答案 1 :(得分:0)

这实际上是一个条件问题。资源都是叶级文件。我的策略没有正确的用户属性值集。我将它与我的LDAP模式进行了比较并使其正常工作。