# OPA Configuration

The `opa` plugin integrates with Open Policy Agent, enabling unified policy definition and enforcement for authorization in API operations.<!-- --> <!-- -->Configuration covers static settings and plugin parameters.

## Static Configurations[​](#static-configurations "Direct link to Static Configurations")

The `apisix.max_request_headers_readable` setting controls how many request headers are included in the OPA input. It is available in APISIX 3.20.0 and API7 Enterprise 3.10.10; earlier versions use a fixed limit of 100 headers.

The configuration source depends on how the gateway is deployed:

* Host or Docker
* API7 Gateway Helm

Set the limit in the persistent gateway configuration:

config.yaml

```
apisix:

  max_request_headers_readable: 200  # Default: 100; 0 reads all request headers.
```

Reload or restart every gateway instance after updating `config.yaml`.

With API7 Gateway Helm chart 3.10.19 or later, set the corresponding chart value:

values.yaml

```
apisix:

  maxRequestHeadersReadable: 200  # Default: 100; 0 reads all request headers.
```

Apply the values file through the gateway release's normal Helm upgrade workflow.

The setting only changes the header table visible to plugins. It does not change NGINX parsing limits; headers beyond the plugin-visible limit can still reach the upstream.

## Parameters[​](#parameters "Direct link to Parameters")

See plugin [common configurations](https://docs.api7.ai/apisix/reference/plugin-common-configurations.md) for configuration options available to all plugins.

* host

  string

  required

  ***

  Address of the OPA server.

* policy

  string

  required

  ***

  Policy to evaluate.

  For example, if you would like to evaluate all rules in a package called `rbac`, configure the policy to be `rbac`.

  The selected OPA document must return an object containing an `allow` decision, for example `{"allow": true}`. A document whose result is the bare Boolean `true` or `false` is not supported.

  You can select a rule inside a package by appending its name, such as `rbac/decision`, when that rule returns the required object.

* ssl\_verify

  boolean

  default: `true`

  ***

  If true, verify the OPA server's SSL certificate.

* timeout

  integer

  default: `3000`

  valid value:

  between 1 and 60000 inclusive

  ***

  Timeout for the HTTP call in milliseconds.

* keepalive

  boolean

  default: `true`

  ***

  If true, keep the connection alive for multiple requests.

* keepalive\_timeout

  integer

  default: `60000`

  valid value:

  greater than or equal to 1000

  ***

  Idle time in milliseconds after which the connection is closed.

* keepalive\_pool

  integer

  default: `5`

  valid value:

  greater than or equal to 1

  ***

  The number of idle connections.

* with\_route

  boolean

  default: `false`

  ***

  If true, send information of the current route.

* with\_service

  boolean

  default: `false`

  ***

  If true, send information of the current service.

* with\_consumer

  boolean

  default: `false`

  ***

  If true, send information of the current consumer.

  Note that the consumer information may include sensitive information such as the API key. Only set this option to `true` if you are sure it is safe to do so.

* send\_headers\_upstream

  array\[string]

  ***

  Header names controlled by the OPA response when the request is allowed. The gateway forwards a configured header when OPA returns it and clears any client-supplied value when OPA omits it.
