Skip to main content

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​

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:

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.

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​

See plugin common configurations 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.