Entitlement Enforcement

Enterprise only

Enforce entitlements by header, with a custom denial responsev3.16+

Use this configuration when your API clients pass a customer or tenant identifier in a request header, instead of authenticating as a Kong Gateway Consumer. This is common for machine-to-machine or multi-tenant SaaS traffic where you don’t create a Consumer per customer.

This example also overrides the default response for USAGE_LIMIT_REACHED, so you can return a status code and message that fit your API’s error format instead of the plugin’s defaults.

Prerequisites

  • Your API clients must pass the customer header on every request you want to enforce entitlements for.

Environment variables

  • ENTITLEMENT_ACCESS_ENDPOINT: The URL of your entitlement access service endpoint.

  • ENTITLEMENT_ACCESS_API_TOKEN: The bearer token used to authenticate with the entitlement access endpoint.

  • CUSTOMER_HEADER: The name of the request header that contains the customer identifier, for example x-customer-id.

  • FEATURE_KEY: The key identifying the feature to enforce.

  • USAGE_LIMIT_MESSAGE: The message to return when a customer has reached their usage limit for the feature.

  • REDIS_HOST: The hostname of your Redis instance used for caching enforcement state.

Set up the plugin

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!