为此使用 Authzforce 似乎有些矫枉过正,但您可以使用
string-starts-with
和string-at-least-one-member-of
条件来实现此目的,例如:
<Target>
<AnyOf>
<AllOf>
<Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">GET</AttributeValue>
<AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" 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">/v2/entities?type=Car</AttributeValue>
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">/v2/entities?type=Truck</AttributeValue>
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">/v2/entities?type=Bicycle</AttributeValue>
</Apply>
<AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:thales:xacml:2.0:resource:sub-resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true" />
</Apply>
</Condition>
这将<target>
检查GET HTTP 动词,<condition>
确保 - 资源 URL 将匹配Truck
,Car
或Bicycle