Skip to content

Latest commit

 

History

History
95 lines (62 loc) · 5.11 KB

File metadata and controls

95 lines (62 loc) · 5.11 KB
description
This page provides the technical details of the Resource Filtering policy

Resource Filtering

Overview

You can use the resource-filtering policy to filter REST resources. By applying this filter, you can restrict or allow access to a specific resource determined by a path and a method (or an array of methods).

This policy is mainly used in plan configuration, to limit subscriber access to specific resources only.

A typical usage would be to allow access to all paths (/**) but in read-only mode (GET method).

Functional and implementation information for the resource-filtering policy is organized into the following sections:

Examples

{% hint style="warning" %} This policy can be applied to v2 APIs and v4 proxy APIs. It cannot be applied to v4 message APIs. {% endhint %}

{% tabs %} {% tab title="Proxy API example" %} Sample policy configuration:

"resource-filtering" : {
    "whitelist":[
        {
            "pattern":"/**",
            "methods": ["GET"]
        }
    ]
}

{% endtab %} {% endtabs %}

Configuration

The implementation of the resource-filtering policy supports Ant-style path patterns, where URL mapping matches URLs using the following rules:

  • ? matches one character
  • * matches zero or more characters
  • ** matches zero or more directories in a path

Phases

The phases checked below are supported by the resource-filtering policy:

v2 PhasesCompatible?v4 PhasesCompatible?
onRequesttrueonRequesttrue
onResponsefalseonResponsefalse
onRequestContentfalseonMessageRequestfalse
onResponseContentfalseonMessageResponsefalse

Options

The resource-filtering policy can be configured with the following options:

PropertyRequiredDescriptionTypeDefault
whitelistfalseList of allowed resourcesarray of resources-
blacklistfalseList of restricted resourcesarray of resources-

{% hint style="info" %} You can’t apply whitelisting and blacklisting to the same resource. Whitelisting takes precedence over blacklisting. {% endhint %}

A resource is defined as follows:

PropertyRequiredDescriptionTypeDefault
patterntrueAn Ant-style path pattern (Apache Ant).string-
methodsfalseList of HTTP methods for which filter is applied.array of HTTP methodsAll HTTP methods

Compatibility matrix

The following is the compatibility matrix for APIM and the resource-filtering policy:

Plugin VersionSupported APIM versions
1.xAll

Errors

HTTP status code Message
403 Access to the resource is forbidden according to resource-filtering rules
405 Method not allowed while accessing this resource

You can use the response template feature to override the default responses provided by the policy. These templates must be defined at the API level (see the API Console Response Templates option in the API Proxy menu).

The error keys sent by this policy are as follows:

KeyParameters
RESOURCE_FILTERING_FORBIDDENpath - method
RESOURCE_FILTERING_METHOD_NOT_ALLOWEDpath - method

Changelogs

{% @github-files/github-code-block url="https://github.com/gravitee-io/gravitee-policy-resource-filtering/blob/master/CHANGELOG.md" %}