Skip to content

Latest commit

 

History

History
109 lines (80 loc) · 4.74 KB

File metadata and controls

109 lines (80 loc) · 4.74 KB
description
This page provides the technical details of the GeoIP Filtering policy

GeoIP Filtering

{% hint style="warning" %} This feature requires Gravitee's Enterprise Edition. {% endhint %}

Overview

{% hint style="warning" %} To use this policy, you must first install the plugin gravitee-service-geoip. This plugin loads the geoip databases in memory, so you need to adjust the JVM Heap settings of your APIM Gateways accordingly. {% endhint %}

You can use the geoip-filtering policy to control access to your API by filtering IP addresses. You can allow IPs by country or distance.

Whitelist mode excludes all IP addresses except the addresses included in the whitelist.

Functional and implementation information for the geoip-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:

"geoip-filtering": {
  "failOnUnknown": true,
  "whitelistRules": [
    {
        "type": "COUNTRY",
        "country": "FR"
    },
   {
       "type": "DISTANCE",
       "distance": "50000"
   }
  ],
}

{% endtab %} {% endtabs %}

Configuration

Sample policy configuration:

{% code title="Sample Configuration" %}

{
  "name": "Custom name",
  "description": "Filters IP addresses",
  "policy": "geoip-filtering",
  "configuration": {
    "failOnUnknown": true,
    "whitelistRules": [
      {
          "type": "COUNTRY",
          "country": "FR"
      },
     {
         "type": "DISTANCE",
         "distance": "50000"
     }
    ],
  }
}

{% endcode %}

Phases

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

v2 PhasesCompatible?v4 PhasesCompatible?
onRequesttrueonRequesttrue
onResponsefalseonResponsefalse
onRequestContentfalseonMessageRequestfalse
onResponseContentfalseonMessageResponsefalse

Options

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

PropertyRequiredDescriptionTypeDefault
failOnUnknowntrueIf set to true, each unknown IP is rejectedbooleantrue
whitelistRulesfalseA list of allowed rulesWhitelist Ruleempty

Whitelist rule

The geoip-filtering policy has the following whitelist rules:

PropertyRequiredDescriptionTypeDefault
TypetrueType of rule COUNTRY or DISTANCEenumCOUNTRY
CountryfalseCountry (must be defined in case type is set to COUNTRY)enumA1
LatitudefalseLatitude (must be defined in case type is set to DISTANCE)number0.0
LongitudefalseLongitude (must be defined in case type is set to DISTANCE)number0.0
DistancefalseMax distance, in meters (must be defined in case type is set to DISTANCE)integer10000

Compatibility matrix

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

Plugin VersionSupported APIM versions
1.xUp to 3.20.x
2.x+4.0.x+

Errors

HTTP status codeError template key
403You’re not allowed to access this resource