Политики XACML — использование регулярных выражений для значений атрибутов внутри условий

Я хочу использовать регулярное выражение для значений атрибутов, чтобы они соответствовали именам ресурсов. Например, http://localhost.*/private/team, чтобы совпадали следующие значения

http://localhost:8080/private/team, http://localhost:8080/abcd/private/team

У меня следующая политика

    <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"/>
                </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://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"/>
                   </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"/>
                   </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"/>
             </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"/>
                   </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"/>
             </Apply>
          </Condition>
       </Rule>
       <Rule Effect="Deny" RuleId="Rule_deny_all"/>
    </Policy>        

Ресурсы находятся в теге условия. Я попытался и не смог добавить функцию строкового регулярного выражения внутри условия. Могу ли я добавить функции регулярных выражений внутри авоськи? Или мне нужно переместить его в цель? Как я могу этого добиться?

С уважением, Альби Моркен.


person Albie Morken    schedule 17.10.2017    source источник


Ответы (1)


В вашем примере вы можете просто использовать одну из следующих функций XACML:

  • stringContains (urn:oasis:names:tc:xacml:3.0:function:string-contains)
  • stringEndsWith (urn:oasis:names:tc:xacml:3.0:function:string-ends-with)

Редактировать

Эти две функции работают с атомарными значениями, например. "a" или "b". По умолчанию атрибуты в XACML — это сумки. Это означает, что роль представляет собой набор значений (может быть 0, 1 или более значений, тем не менее это пакет). Это означает, что если вы хотите использовать stringContains() для сумки, вам нужно либо сначала использовать stringOneAndOnly, чтобы преобразовать сумку в одно значение, либо вам нужно использовать функцию более высокого порядка.

строкаOneAndOnly

Например, попробуйте следующее (используя нотацию ALFA)

// The result SHALL be true if the second string contains the first string, and false otherwise.
stringContains("manager", stringOneAndOnly(role))

Функции высшего порядка

В качестве альтернативы вы можете использовать AnyOf или AnyOfAny, примененные к stringContains().

person David Brossard    schedule 17.10.2017
comment
Но как я могу использовать его с авоськой? Мне нужно что-то вроде приведенного ниже ‹Apply FunctionId=urn:oasis:names:tc:xacml:3.0:function:string-ends-with› ‹Apply FunctionId=urn:oasis:names:tc:xacml:1.0:function:string -bag› ‹AttributeValue DataType=http://www.w3.org/2001/XMLSchema#string›http://localhost.*/private/support‹/AttributeValue› ‹AttributeValue DataType=http://www.w3.org/2001/XMLSchema#string›http://localhost.*/private/team‹/AttributeValue› ‹/Apply› Есть ли другой способ проверить строки, заканчивающиеся на список ? - person Albie Morken; 19.10.2017