3

WSO2 Balana ライブラリで使用している XACML ポリシーについて質問があります。

ポリシーを持つ:

<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="Policy1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable" 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">MyApp</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="Permit" RuleId="RuleFor_user1_myapp">
        <Target>
            <AnyOf>
                <AllOf>
                    <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">user1</AttributeValue>
                        <AttributeDesignator AttributeId="http://example.site.com/id/user" 
                                       Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" 
                                       DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"/>
                    </Match>
                </AllOf>           
            </AnyOf>
        </Target>
        <Apply  FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of">
            <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag">
                <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">READ</AttributeValue>                                
            </Apply>
            <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"/>
        </Apply>
    </Rule>   
</Policy>   

user1 が MyApp に対する READ 権限のみを持つことを定義する必要があります。

user1 に READ 権限があるかどうかを確認する評価リクエストがあり、応答で「許可」を取得していますが、これで問題ありません。

しかし、user1 に WRITE 権限があるかどうかを尋ねる評価要求があると、「該当なし」ではなく「許可」も取得されます。

私が今説明した結果を生み出すためにポリシーが正しいかどうか誰か教えてもらえますか?

前もって感謝します!

敬具、 ジュリカ・クリザニッチ

4

2 に答える 2

3

http://validator.xacml.eu/を使用して、XACML ポリシーが XACML 2.0 または XACML 3.0 準拠であることを確認できます。

また、ALFA を使用してポリシーを作成することをお勧めします。ALFA の方が簡単で、Eclipse と統合できます。

ALFA コードは次のようになります。

namespace sample{
    // Import standard XACML attributes
    import Attributes.*

    /**
     * Define custom attributes here
     */
    attribute user{
        category = subjectCat
        id = "http://example.site.com/id/user"
        type = string
    }

    /**
     * MyApp Policy
     */
    policy Policy1{
        target clause resourceId=="MyApp"
        apply firstApplicable
        /**
         * This rule grants READ access for user 1
         */
        rule RuleFor_user1_myapp{
            target clause user=="user1" and actionId=="READ"
            permit
        }
    }
}

生成された XACML 3.0 は次のようになります。

<?xml version="1.0" encoding="UTF-8"?>
 <!--This file was generated by the ALFA Plugin for Eclipse from Axiomatics AB (http://www.axiomatics.com). 
 Any modification to this file will be lost upon recompilation of the source ALFA file-->
<xacml3:Policy xmlns:xacml3="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
    PolicyId="http://axiomatics.com/alfa/identifier/sample.Policy1"
    RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable"
    Version="1.0">
    <xacml3:Description>MyApp Policy</xacml3:Description>
    <xacml3:PolicyDefaults>
        <xacml3:XPathVersion>http://www.w3.org/TR/1999/REC-xpath-19991116</xacml3:XPathVersion>
    </xacml3:PolicyDefaults>
    <xacml3:Target>
        <xacml3:AnyOf>
            <xacml3:AllOf>
                <xacml3:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                    <xacml3:AttributeValue
                        DataType="http://www.w3.org/2001/XMLSchema#string">MyApp</xacml3:AttributeValue>
                    <xacml3:AttributeDesignator 
                        AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id"
                        DataType="http://www.w3.org/2001/XMLSchema#string"
                        Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
                        MustBePresent="false"
                    />
                </xacml3:Match>
            </xacml3:AllOf>
        </xacml3:AnyOf>
    </xacml3:Target>
    <xacml3:Rule 
            Effect="Permit"
            RuleId="http://axiomatics.com/alfa/identifier/sample.Policy1.RuleFor_user1_myapp">
        <xacml3:Description>This rule grants READ access for user 1</xacml3:Description>
        <xacml3:Target>
            <xacml3:AnyOf>
                <xacml3:AllOf>
                    <xacml3:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                        <xacml3:AttributeValue
                            DataType="http://www.w3.org/2001/XMLSchema#string">user1</xacml3:AttributeValue>
                        <xacml3:AttributeDesignator 
                            AttributeId="http://example.site.com/id/user"
                            DataType="http://www.w3.org/2001/XMLSchema#string"
                            Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
                            MustBePresent="false"
                        />
                    </xacml3:Match>
                    <xacml3:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                        <xacml3:AttributeValue
                            DataType="http://www.w3.org/2001/XMLSchema#string">READ</xacml3:AttributeValue>
                        <xacml3:AttributeDesignator 
                            AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id"
                            DataType="http://www.w3.org/2001/XMLSchema#string"
                            Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action"
                            MustBePresent="false"
                        />
                    </xacml3:Match>
                </xacml3:AllOf>
            </xacml3:AnyOf>
        </xacml3:Target>
    </xacml3:Rule>
</xacml3:Policy>
于 2013-03-02T04:34:17.370 に答える
3

まず、ポリシーは XACML3 スキーマで有効なものではありません。ルールには Apply 要素で囲まれた要素が必要です。ルールには基本的に、Target 要素と Condition 要素が含まれます。Balana は、ポリシーでスキーマ検証を行っていません。ポリシー要素を使用してオブジェクト モジュールを構築します。ルールで要素が見つからないため、要素を無視しました。したがって、実際には、ルールには subject 属性のみを評価する target 要素しかありません。以下のようにご利用ください。また、ポリシーを WSO2 Identity サーバーにアップロードするときに、スキーマの検証が行われます。ポリシーを簡単にアップロードまたは作成できます。

于 2013-03-01T12:03:44.703 に答える