<!-- Generated by website/scripts/sync-docs.mjs from docs/configuration.md. Edit that file, not this one. -->

# Configuration

> Every page of this site: https://dyokto.github.io/opa-authzen-plugin/llms.txt

The plugin is configured under the `plugins.authzen` key in the OPA config file:

| Key                 | Type   | Default   | Description                                                              |
| ------------------- | ------ | --------- | ------------------------------------------------------------------------ |
| `path`              | string | `authzen` | OPA package path to query                                                |
| `decision`          | string | `allow`   | Rule name within the package that produces the boolean decision          |
| `decision_context`  | string | _(unset)_ | Rule name whose object value is returned as the Decision's optional `context` |
| `search.subject`    | string | _(unset)_ | Rule name returning the set of permitted subjects (enables Subject Search)  |
| `search.resource`   | string | _(unset)_ | Rule name returning the set of permitted resources (enables Resource Search) |
| `search.action`     | string | _(unset)_ | Rule name returning the set of permitted actions (enables Action Search)    |
| `search.max_limit`  | int    | `1000`    | Per-page cap; client `page.limit` is clamped to this value               |
| `capabilities`      | array  | _(unset)_ | PDP capability URNs advertised in the `capabilities` field of the PDP metadata |
| `supported_obligations` | array | _(unset)_ | Obligation Types advertised in the PDP metadata; also bounds the PEP-declared set and the obligations returned on each request |
| `access_request_endpoint` | string | _(unset)_ | HTTPS URI advertised as `access_request_endpoint` in the PDP metadata (Access Request and Approval Profile) |
| `jwks_uri`          | string | _(unset)_ | HTTPS URI advertised as `jwks_uri` in the PDP metadata, for verifying signed values issued under that profile |
| `signed_metadata`   | string | _(unset)_ | Compact JWS advertised as `signed_metadata` in the PDP metadata (spec Section 9.1.3) |

If a `search.*` rule is unset, the corresponding endpoint responds with 501 and is omitted from the PDP metadata (spec Section 9). Each configured rule must be defined in the package given by `path` and return a set/array of entity objects.

When `decision_context` is set, the named rule is evaluated alongside the decision (under the same policy/data snapshot) and its result is returned as the Decision's optional `context` member (spec Section 5.5.1), letting a policy convey reasons, obligations, or other metadata. The rule must evaluate to a JSON object; an undefined result or an empty object omits `context`, and a non-object result fails the request. `decision_context` is unset by default, so responses carry only `decision` unless you opt in.

The decision and its context are evaluated in a single query, so they come from one evaluation of one policy/data snapshot. A rule both depend on — typically when the decision is derived from the context — is evaluated once per decision, and so is every builtin it calls: an `http.send` to an external PIP, or a relationship check against an external store, is made once, and the context always describes the evaluation that produced the decision. In a batch with `deny_on_first_deny` or `permit_on_first_permit`, the item that ends the batch is answered with the plugin's reason context, so the `decision_context` rule is not evaluated for it.

The AuthZEN core specification registers no capability URNs of its own (the IANA "AuthZEN Policy Decision Point Capabilities" registry is populated by profiles and vendors), so `capabilities` is operator-supplied. Each entry must be a URN (start with `urn:`); the list is omitted from the metadata when empty. A deployment running the [Access Request and Approval profile](https://openid.github.io/authzen/authzen-access-request-approval-profile-1_0.html) advertises `urn:openid:authzen:capability:access-request` here — see [below](#access-request-and-approval-profile).

`signed_metadata` is a JWT that asserts PDP metadata values as claims, signed or MACed with JWS and carrying an `iss` claim (spec Section 9.1.3). A PEP that supports it must prefer the signed values over the plain ones. The plugin holds no key and does not sign it: sign the JWT outside the plugin and paste the compact serialization into the config. At startup the plugin rejects a value that is not a three-part base64url JWS on one line, has no signature, has a missing or `none` `alg`, has a missing or empty `iss`, or contains a `signed_metadata` claim. It also rejects claims that disagree with the config: `capabilities` and `supported_obligations` must be string arrays holding the configured values, `access_request_endpoint` and `jwks_uri` must be the configured strings, and a `search_*_endpoint` claim must be a string and requires that search to be configured. The signature itself is not verified. Endpoint URLs in the plain document are built from the request's `Host` and `X-Forwarded-*` headers, so a PEP that needs them pinned should read them from the signed claims.

## Obligations Core

`supported_obligations` opts the PDP into the [AuthZEN Obligations Core (Draft 1)](https://openid.github.io/authzen/authzen-obligations-core-1_0.html). Set it to the Obligation Types your policies may issue — a type from the [Standard Types Profile](https://openid.github.io/authzen/authzen-obligations-standard-types-profile-1_0.html) (`step-up`, `notification`, `session_termination`) or the literal `custom`. The "AuthZEN Obligation Types" registry is IANA "Specification Required" and therefore extensible, so unregistered values are accepted; only empty entries are rejected at startup.

The list does three things.

- It is advertised as the `supported_obligations` member of the PDP metadata, and `urn:openid:authzen:capability:obligations` is added to `capabilities`, so a PEP can discover the extension and the types it must be prepared to execute. If you also set `signed_metadata`, its `capabilities` claim has to include that URN.
- It bounds the PEP's own `context.supported_obligations` array on each request. The extension requires a PDP to ignore any declared value it did not itself advertise, so the plugin filters the member before the input reaches Rego, and your policy can trust every entry is a type this PDP is configured to issue. A member that is not an array is removed. A PEP that adopted the extension (below) and sent no usable array gets an empty one, which is how the extension says to read the omission.
- It bounds what leaves the PDP. A PEP adopts the extension by listing `obligations` in `context.supported_mandatory_extensions`. After the policy runs, the plugin applies the extension's PDP outcome rule to the `obligations` member of the Decision context: a PEP that has not adopted the extension never receives it, and if the policy required an obligation the decision becomes a deny; an adopting PEP never receives an obligation whose `type` it did not list, and if the policy required one the decision becomes a deny that keeps only the listed ones. An empty `obligations` array requires nothing: it is removed and the decision stands, since the extension only allows a non-empty array.

The obligations themselves ride in the Decision `context`, which the `decision_context` rule supplies, so a policy issuing obligations sets both keys:

```yaml
plugins:
  authzen:
    decision_context: obligations_ctx
    supported_obligations:
      - step-up
      - notification
```

```rego
package authzen

obligations_ctx := {"obligations": [{
    "id": "step-up-1",
    "type": "step-up",
    "properties": {"acr_value": "urn:com:example:loa:3"}
}]} if {
    not allow
    "step-up" in input.context.supported_obligations
}
```

Because the plugin enforces the outcome rule, the policy does not have to check `supported_mandatory_extensions` itself; checking `supported_obligations` lets it pick a type the PEP can execute instead of ending in a deny. In a batch, the rule runs per evaluation, and a result that ends the batch under `deny_on_first_deny` or `permit_on_first_permit` keeps its `obligations` next to the reason. In Search, a result entity may carry its own `context` with `obligations`; the rule runs per result, and a result whose obligations the PEP may not receive is left out of the results, as if access to it had been denied.

The opt-in changes what a PEP receives, so the extension requires the PDP to honor it only from an authenticated PEP. The plugin does not authenticate callers itself. Run OPA with `--authentication` and `--authorization`, which cover the AuthZEN endpoints too, or put an authenticating proxy (mTLS, for example) in front of it. A PEP that forwards its own callers' `context` unchecked lets them forge the opt-in.

Leaving `supported_obligations` unset means the PDP does not implement the extension: the metadata member is omitted, request context reaches the policy untouched, and the Decision context is returned as the policy wrote it. If your policy already reads `input.context.supported_obligations` for its own purposes, note that opting in changes what it sees.

The plugin paginates over the **entire** result set returned by the Rego rule, sorting by the entity's `type`+`id` (or `name` for actions) so page boundaries are stable across requests. If your search rules can return very large candidate sets (tens of thousands), prefer filtering inside Rego rather than relying on the plugin's per-page slicing — the rule still runs once per page request, so heavy candidate sets are paid for every call.

## Access Request and Approval Profile

The [Access Request and Approval Profile (Draft 1)](https://openid.github.io/authzen/authzen-access-request-approval-profile-1_0.html) turns a denial into something a PEP can act on: the PDP marks a denial as _requestable_, and the PEP submits an access request that a human or workflow can approve.

**This plugin implements the PDP discovery half of the profile, not the Access Request Service.** That split is one the profile itself allows — the Access Request Endpoint "MAY be hosted by the PDP itself, by a service trusted by the PDP, or by an independent service operating with delegated authority from the PDP". The endpoint, the Task Status Endpoint, and the approval workflow behind them are stateful, OAuth-protected services; this plugin advertises where they live and lets your policy emit the requestable-denial hint.

Two config keys feed the PDP metadata document:

```yaml
plugins:
  authzen:
    decision_context: denial_ctx
    access_request_endpoint: "https://requests.example.com/access/v1/requests"
    jwks_uri: "https://requests.example.com/access/v1/jwks"
    capabilities:
      - "urn:openid:authzen:capability:access-request"
```

Both must be `https://` URIs with a host; a bad value fails at startup rather than being published to every PEP that reads the metadata. Both are unset by default and omitted from the metadata when unset — and the absence of `access_request_endpoint` is exactly how a PEP learns this PDP advertises no Access Request Endpoint. `jwks_uri` is only needed when the deployment issues signed values under the profile, such as a JWS `binding_token`, so it can be left unset while the endpoint is advertised — but see the binding forms below: a deployment whose Access Request Service is independent of the PDP has to issue that token, and therefore has to publish the key.

The requestable-denial hint itself is policy output, carried by the existing `decision_context` rule. The example below binds the denial by reference, so it assumes the shared-state topology described under the binding forms: something outside the plugin must record what the Access Request Service will later resolve from `evaluation_id`, since a stateless OPA records nothing.

```rego
package authzen

denial_ctx := {
    "reason": "approval_required",
    "evaluation_id": input.context.request_id,
    "access_request": {
        "template": "manager_approval",
        "expires_at": "2026-09-02T20:25:00Z",
    },
} if {
    not allow
    input.resource.properties.sensitivity == "high"
}
```

The profile requires `expires_at` on every requestable denial, and requires denial-binding material in at least one of two forms, and which form is available to you depends on your topology. A stable `evaluation_id` binds _by reference_ and applies only where the Access Request Service resolves it against state shared with, or delegated by, the PDP; a signed `binding_token` binds _by value_ and works in any topology. Where the Access Request Service is independent of the PDP, the profile requires the `binding_token` form and requires that token to be self-contained — carrying the denied Subject, Resource, Action, and authorization-relevant Context inline or as a `binding_hash` — because a stateless PDP keeps no decision state for an independent service to fetch. A `binding_token` carrying only an `evaluation_id` does not satisfy that requirement. Emitting both forms is allowed and is worth doing: the profile still recommends a stable `context.evaluation_id`, and when a `binding_token` is present that identifier stops being a binding form and serves as a correlation and audit identifier instead. Both values come from your policy or a PDP-side signer; the plugin passes the `decision_context` object through unchanged and does not synthesize, sign, or validate them, so a deployment that needs the `binding_token` form must sign it outside the plugin and publish the verification key at `jwks_uri`. Emit `context.access_request` **only** when an Access Request Endpoint is actually able to process the request — the profile makes the presence of that object the sole signal that a denial is requestable.

## Decision logs

AuthZEN decisions are written to [OPA's decision log](https://www.openpolicyagent.org/docs/management-decision-logs), next to the Data API's. OPA's server only logs the routes it serves itself, so the plugin logs the decisions it evaluates. Nothing is configured on the plugin: when OPA's `decision_logs` is configured, AuthZEN decisions are logged; when it is not, nothing is logged, as for the Data API.

```yaml
plugins:
  authzen: {}
decision_logs:
  console: true
  request_context:
    http:
      headers: [X-Request-ID]
```

Each decision is one event:

| Field | Value |
| ----- | ----- |
| `path` | `<path>/<decision>`, e.g. `authzen/allow`; for a search, `<path>/<search rule>` |
| `input` | The input the rule was evaluated with: subject, action, resource and context after validation, batch default merging (Section 7.1.1) and obligation negotiation |
| `result` | The Decision returned for it, `{"decision": ..., "context": ...}`; for a search, the response page (`results` and `page`) |
| `error` | The evaluation error, instead of `result`, when the policy fails to evaluate |
| `decision_id` | A new ID per decision, also set on the span as `opa.decision_id` except for batch items |
| `batch_decision_id` | For `/access/v1/evaluations` with an `evaluations` array, one ID shared by the items of the request |
| `metrics` | The metrics of the query that evaluates the decision and its `decision_context` |
| `nd_builtin_cache` | With `nd_builtin_cache: true`, the non-deterministic builtin results of that query |
| `requested_by`, `req_id`, `timestamp`, `bundles`, `labels` | As for the Data API |

`POST /access/v1/evaluations` logs one event per evaluated item, including a short-circuited item with the reason context it was answered with. Requests and batch items rejected before evaluation, such as one with a missing or malformed subject, action or resource, are not decisions and are not logged. A request without an `evaluations` array is a single evaluation and is logged as one, without a `batch_decision_id`.

The `system.log` mask and drop policies apply as usual, so for example `mask contains "/input/subject/properties"` erases subject properties from AuthZEN decisions too. The AuthZEN `X-Request-ID` header (Section 10.1.3) is logged under `request_context` when listed in `decision_logs.request_context.http.headers`, as in the example. Logging never changes the response: unlike the Data API, the AuthZEN response carries no `decision_id`, and a decision log error is reported in OPA's log without failing the request.
