XACML政策 - 获取"不确定"响应

时间:2017-10-16 13:39:14

标签: authorization wso2is access-control xacml abac

我正在尝试在WSO2中探索XACML。我在WSO2 IS 5.3.0中使用以下政策

    <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"  PolicyId="InStorePolicy" 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">access</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>
             </AllOf>
          </AnyOf>
       </Target>
       <Rule Effect="Permit" RuleId="Rule_for_employee">
          <Target>
             <AnyOf>
                <AllOf>
                   <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                      <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Employee</AttributeValue>
                      <AttributeDesignator AttributeId="http://test.org/claim/role" Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
                   </Match>
                </AllOf>
                <AllOf>
                   <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                      <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Manager</AttributeValue>
                      <AttributeDesignator AttributeId="http://wso2.org/claims/role" Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
                   </Match>
                </AllOf>
             </AnyOf>
          </Target>
          <Condition>
             <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">private/support</AttributeValue>
                   <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">private/team</AttributeValue>
                </Apply>
                <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>
             </Apply>
          </Condition>
       </Rule>
       <Rule Effect="Permit" RuleId="Rule_for_manager">
          <Target>
             <AnyOf>
                <AllOf>
                   <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                      <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Manager</AttributeValue>
                      <AttributeDesignator AttributeId="http://wso2.org/claims/role" Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
                   </Match>
                </AllOf>
             </AnyOf>
          </Target>
          <Condition>
             <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">private</AttributeValue>
                   <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">private/business</AttributeValue>
                   <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">private/leadership</AttributeValue>
                </Apply>
                <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>
             </Apply>
          </Condition>
       </Rule>
       <Rule Effect="Deny" RuleId="Rule_deny_all"></Rule>
    </Policy>        

我创建了具有Manager和Employee角色的用户。但是,当我使用&#39; Tryit&#39;时,如果使用以下值,我会得到&#34; Indeterminate&#34;

行动:访问, 主题:employee1, 资源:/ private / team

另外,我得到了&#34;无法找到AttributeDesignator属性&#34;服务器控制台中的错误。我无法找到更多细节。

有人可以帮我理解这个问题吗?

-Albie Morken

1 个答案:

答案 0 :(得分:1)

我使用Axiomatics Policy Server尝试了您的策略,我相信我可能找到了您的问题的根本原因。您的部分属性标记为MustBePresent。这是一个可选标志,如果设置为true,如果您的属性没有值,则会使评估返回Indeterminate。

访问审核

以下是授予访问权限的三种不同方式:

  1. stringAtLeastOneMemberOf(stringBag("private/support" , "private/team") , Attributes.resource.resource_id ) AND "access" == Attributes.action.action_id AND "Employee" == http://test.org/claim/role

  2. "Manager" == http://wso2.org/claims/role AND stringAtLeastOneMemberOf(stringBag("private/support" , "private/team") , Attributes.resource.resource_id ) AND "access" == Attributes.action.action_id

  3. "Manager" == http://wso2.org/claims/role AND "access" == Attributes.action.action_id AND stringAtLeastOneMemberOf(stringBag("private" , "private/business" , "private/leadership") , Attributes.resource.resource_id )

  4. 上面的表示法使用ALFA,即授权的缩写语言。

    政策审查

    这是您的政策在政策编辑器中的样子。

    Axiomatics Policy Editor

    您的政策BTW中有一些奇怪的事情:

    1. 您使用2个相似且不同的属性标识符(http://wso2.org/claims/rolehttp://test.org/claim/role)。这是故意的吗?
    2. 您所描述的任何政策和规则都没有让您更难理解。
    3. 我不确定您需要将属性标记为MustBePresent。我通常不这样做,但这可能是一种偏好。
    4. 您可以在简单目标执行时使用条件
    5. 之前

      The rule before update

      以下内容比前者更容易阅读。

      The rule with a combined target

      样本请求/响应

      以下示例利用XACML的JSON配置文件(Wikipedia | Blog post

      {
          "Request": {
              "AccessSubject": {
                  "Attribute": [
                      {
                          "AttributeId": "http://test.org/claim/role",
                          "Value": "Employee"
                      }
                  ]
              },
              "Resource": {
                  "Attribute": [
                      {
                          "AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id",
                          "Value": "private/support"
                      }
                  ]
              },
              "Action": {
                  "Attribute": [
                      {
                          "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
                          "Value": "access"
                      }
                  ]
              },
              "Environment": {
                  "Attribute": []
              }
          }
      }
      

      匹配响应

      {
        "Response" : {
          "Decision" : "Permit",
          "Status" : {
            "StatusCode" : {
              "Value" : "urn:oasis:names:tc:xacml:1.0:status:ok",
              "StatusCode" : {
                "Value" : "urn:oasis:names:tc:xacml:1.0:status:ok"
              }
            }
          }
        }
      }