Skip to content

Latest commit

 

History

History
76 lines (50 loc) · 3.04 KB

File metadata and controls

76 lines (50 loc) · 3.04 KB
description
This page provides the technical details of the API Key policy

API Key

Overview

You can use the api-key policy to enforce API key checks during request processing, allowing only apps with approved API keys to access your APIs.

This policy ensures that API keys are valid, have not been revoked or expired and are approved to consume the specific resources associated with your API.

Functional and implementation information for the api-key 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" %} You can configure the policy in the APIM Gateway configuration file (gravitee.yml). You can customize the X-Gravitee-Api-Key header and api-key query parameter.

policy:
  api-key:
    header: My-Custom-Api-Key
    param: custom-api-key

{% endtab %} {% endtabs %}

Configuration

Sample policy configuration:

{% code title="Sample Configuration" %}

"api-key": {
  "propagateApiKey": false
}

{% endcode %}

Phases

The phases checked below are supported by the api-key policy:

v2 PhasesCompatible?v4 PhasesCompatible?
onRequesttrueonRequesttrue
onResponsefalseonResponsefalse
onRequestContentfalseonMessageRequestfalse
onResponseContentfalseonMessageResponsefalse

Options

You can configure the api-key policy with the following options:

PropertyRequiredDescriptionTypeDefault
propagateApiKeyfalsePropagate API key to upstream APIbooleanfalse

Compatibility matrix

The following is the compatibility matrix for APIM and the assign-metrics policy:

Plugin VersionSupported APIM versions
2.x3.x
4.x4.0+

Errors

PhaseKey
onRequestAPI_KEY_MISSING
API_KEY_INVALID_KEY

Changelogs

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