2013-03-01 4 views
3

WSO2 Balana 라이브러리와 함께 사용하고있는 XACML 정책에 대한 질문이 있습니다.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> 

그것은 단지의 MyApp에 읽기 권한이 사용자 1을 정의한다 :

정책을 가졌어요.

user1에 읽기 권한이 있는지 묻는 평가 요청이 있는데 응답에 "허가"가 표시됩니다.

그러나 user1에게 쓰기 권한이 있는지 묻는 평가 요청이있을 때 "적용되지 않음"대신 "허가"도 표시됩니다.

내가 방금 설명한 결과를 내놓는 데 정책이 맞다고 말할 수 있습니까?

미리 감사드립니다.

안부, 리카 Krizanic

답변

3

http://validator.xacml.eu/을 사용하면 XACML 정책이 XACML 2.0 또는 XACML 3.0을 준수하는지 확인할 수 있습니다.

또한 정책을 작성하는 데는 ALFA를 사용하는 것이 좋습니다.이 방법이 더 쉽고 Eclipse와 통합됩니다.

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> 
+0

XACML 검사기 웹 사이트가 더 이상 작동하지 않습니다. 사용할 수있는 다른 유효성 검사기가 있습니까? – Ozkan

+1

XACML 3.0 스키마와 표준 XML 유효성 검사 도구를 사용하십시오. 메모장 + + 또는 XML 스파이 ... –

3

우선은 정책이 XACML3 스키마에 유효한 하나되지 않는 것입니다. 규칙에 Apply 요소로 묶인 요소가 있어야합니다. 규칙은 기본적으로 대상 및 조건 요소를 포함합니다. Balana는 귀하의 정책으로 스키마 유효성 검사를 수행하지 않습니다. 정책 요소를 사용하여 개체 모듈을 작성합니다. 규칙에서 요소를 찾을 수 없으므로 요소를 무시했습니다. 따라서 귀하의 규칙에는 실제로 주제 속성 만 평가하는 대상 요소 만 있습니다. 다음과 같이 사용하십시오. 또한 WSO2 Identity 서버에 정책을 업로드 할 때 스키마 유효성 검사를 수행합니다. 정책을 쉽게 업로드하거나 만들 수 있습니다.

+0

감사합니다. –