【问题标题】:Correct approach to use XACML at granular level在粒度级别使用 XACML 的正确方法
【发布时间】:2015-02-20 16:41:14
【问题描述】:

我正在开展一个项目,我们希望在该项目中集中访问控制。

当我们遇到以下情况时,我无法理解如何在访问控制中使用粒度:

医生只能访问分配给他的患者。

现在,我们可以有很多这样的用例,也可以有一些动态用例,比如:

客户部门看不到患者详细信息,但医生更改了状态 耐心,并让他到客户部门。

那么如何处理这种动态随机变化。

【问题讨论】:

    标签: wso2 authorization access-control xacml alfa


    【解决方案1】:

    在具体规则中引入condition

    <Policy PolicyId="deny-apia" RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable"
             xmlns="urn:oasis:names:tc:xacml:1.0:policy" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <Description>...</Description>
        <Target/>       
        <Rule RuleId="1" Effect="Permit">
            <Target>
                <Subjects>
            ...
                </Subjects>
                <Resources>
            ...
                </Resources>
                <Actions>
            ...
                </Actions>
                <Environment>
            ...
                </Environment>
            </Target>
            <Condition>
                <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:function:string-equal">
    
                </Apply>
            </Condition>
        </Rule>
        <Rule RuleId="DenyAllThatDidNotMatchPreviousRules" Effect="Deny"/>
    </Policy>
    
    1. 如果医师通过上传同意书更改状态,则规则 将适用,并且患者的详细信息可以由 部门。
    2. 如果未获得同意,则该规则不适用,并且 成员拒绝访问患者详细信息 部门。
    3. 如果医疗保健提供者撤销同意,客户部门的访问权限将被撤销,并且该规则不再适用。

    XACML 中的另一个条件示例位于here

      <Policy PolicyId="SamplePolicy"
              RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:permit-overrides">
    
        <!-- This Policy only applies to requests on the SampleServer -->
        <Target>
          <Subjects>
            <AnySubject/>
          </Subjects>
          <Resources>
            <ResourceMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
              <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleServer</AttributeValue>
              <ResourceAttributeDesignator DataType="http://www.w3.org/2001/XMLSchema#string"
                                           AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id"/>
            </ResourceMatch>
          </Resources>
          <Actions>
            <AnyAction/>
          </Actions>
        </Target>
    
        <!-- Rule to see if we should allow the Subject to login -->
        <Rule RuleId="LoginRule" Effect="Permit">
    
          <!-- Only use this Rule if the action is login -->
          <Target>
            <Subjects>
              <AnySubject/>
            </Subjects>
            <Resources>
              <AnyResource/>
            </Resources>
            <Actions>
              <ActionMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">login</AttributeValue>
                <ActionAttributeDesignator DataType="http://www.w3.org/2001/XMLSchema#string"
                                           AttributeId="ServerAction"/>
              </ActionMatch>
            </Actions>
          </Target>
    
          <!-- Only allow logins from 9am to 5pm -->
          <Condition FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
            <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:time-greater-than-or-equal"
              <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:time-one-and-only">
                <EnvironmentAttributeSelector DataType="http://www.w3.org/2001/XMLSchema#time"
                                              AttributeId="urn:oasis:names:tc:xacml:1.0:environment:current-time"/>
              </Apply>
              <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">09:00:00</AttributeValue>
            </Apply>
            <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:time-less-than-or-equal"
              <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:time-one-and-only">
                <EnvironmentAttributeSelector DataType="http://www.w3.org/2001/XMLSchema#time"
                                              AttributeId="urn:oasis:names:tc:xacml:1.0:environment:current-time"/>
              </Apply>
              <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">17:00:00</AttributeValue>
            </Apply>
          </Condition>
    
        </Rule>
    
        <!-- We could include other Rules for different actions here -->
    
        <!-- A final, "fall-through" Rule that always Denies -->
        <Rule RuleId="FinalRule" Effect="Deny"/>
    
      </Policy>
    

    注意在 XACML 文件的末尾添加一条拒绝规则,该规则拒绝与规则之一不匹配的所有内容。

    【讨论】:

    • 您好,很抱歉,您的回答中没有新内容。无论您解释什么都是 XACMl 的基础知识,而我的问题更多的是 XACML 在现实世界应用中的专家级应用,具有深层次的颗粒化。如果您想了解更多有关它的信息,请仔细阅读我提出的其他问题以及我从 Axiomatics 的 DAVID 和 WSo2 的 aselea 等技术架构师那里得到的答案。
    猜你喜欢
    • 2019-02-11
    • 1970-01-01
    • 2013-11-06
    • 2015-02-21
    • 1970-01-01
    • 2015-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多