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

# Quick start

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

Start opa-authzen-plugin with the example policy from this repository, then send it AuthZEN evaluation requests with `curl`: one that the policy denies, the same request changed so that it is allowed, and one that is rejected before the policy runs. You need `curl` and `jq`, and Go, Docker or nothing else depending on how you install it.

## Install



**Linux and macOS binary**

Releases ship bare binaries, not archives: `opa_authzen_linux_amd64`, `opa_authzen_linux_arm64`, `opa_authzen_darwin_amd64`, `opa_authzen_darwin_arm64` and `opa_authzen_windows_amd64.exe`, from the [releases page](https://github.com/dyokto/opa-authzen-plugin/releases).

```sh
gh release download -R dyokto/opa-authzen-plugin -p opa_authzen_linux_amd64
sudo install opa_authzen_linux_amd64 /usr/local/bin/opa-authzen-plugin
```

**Container image**

Multi-arch (`linux/amd64`, `linux/arm64`) at `ghcr.io/dyokto/opa-authzen-plugin`, tagged with the release version without the `v`.

```sh
docker pull ghcr.io/dyokto/opa-authzen-plugin:0.13.0
```

The image's entrypoint is the plugin binary. In [Start the server](#start-the-server), run the container below instead of the `opa-authzen-plugin run` line, and stop it with `docker rm -f authzen` at the end. `--addr 0.0.0.0:8181` is needed because OPA binds `localhost` by default, which a published port cannot reach.

```sh
docker run -d --name authzen -p 8181:8181 -v "$PWD/example:/example:ro" \
  ghcr.io/dyokto/opa-authzen-plugin:0.13.0 \
  run --server --addr 0.0.0.0:8181 --config-file /example/config.yaml /example/policy.rego
```

**Go**

Needs Go 1.26.1 or later (the `go` line in `go.mod`). Installs to `$(go env GOPATH)/bin`.

```sh
go install github.com/dyokto/opa-authzen-plugin/cmd/opa-authzen-plugin@latest
```



The binary is OPA with the AuthZEN plugin compiled in, so it has every `opa` subcommand. `version` prints the version of OPA it is built on (OPA 1.23.0 for v0.13.0), not the plugin release:

```console
$ opa-authzen-plugin version
Version: 1.23.0
...
```

## Get the example files

The policy and config are [example/policy.rego](https://github.com/dyokto/opa-authzen-plugin/blob/main/example/policy.rego) and [example/config.yaml](https://github.com/dyokto/opa-authzen-plugin/blob/main/example/config.yaml).

```sh
git clone --depth 1 https://github.com/dyokto/opa-authzen-plugin
cd opa-authzen-plugin
```

The config enables the plugin and names the package and rule that decide:

```yaml
plugins:
  authzen:
    path: "authzen"
    decision: "allow"
```

## Start the server

This starts OPA on `localhost:8181` with the AuthZEN endpoints on the same server, in the background, and waits until it answers. `--log-level error` keeps its request log out of your terminal.

```console
$ opa-authzen-plugin run --server --log-level error \
    --config-file example/config.yaml example/policy.rego &
$ until curl -sf -o /dev/null http://localhost:8181/health; do sleep 0.2; done
```

## A request the policy denies

Bob asks to delete a document. Nothing in the policy allows it, so `default allow = false` decides:

```console
$ curl -s http://localhost:8181/access/v1/evaluation \
    -H 'Content-Type: application/json' \
    -d '{"subject": {"type": "user", "id": "bob"}, "action": {"name": "delete"}, "resource": {"type": "document", "id": "doc-123"}}'
{"decision":false}
```

A denial is a `200` response with `"decision": false`, not an HTTP error status.

## The same request, allowed

The first rule in the policy allows any action for a subject with the `admin` role:

```rego
default allow = false

# Allow if the subject has the "admin" role.
allow if input.subject.properties.role == "admin"
```

Send the same request with that property on the subject:

```console
$ curl -s http://localhost:8181/access/v1/evaluation \
    -H 'Content-Type: application/json' \
    -d '{"subject": {"type": "user", "id": "bob", "properties": {"role": "admin"}}, "action": {"name": "delete"}, "resource": {"type": "document", "id": "doc-123"}}'
{"decision":true}
```

## A request that never reaches the policy

A request without `subject`, `action` or `resource` is rejected with `400` before the policy is evaluated:

```console
$ curl -s -w '%{http_code}\n' http://localhost:8181/access/v1/evaluation \
    -H 'Content-Type: application/json' \
    -d '{"subject": {"type": "user", "id": "bob"}}'
{"error":"subject, action, and resource are required"}
400
```

## Several decisions in one request

`/access/v1/evaluations` takes defaults at the top level and one item per decision (Section 7). Reading is allowed for any subject with an `id`; deleting is not:

```console
$ curl -s http://localhost:8181/access/v1/evaluations \
    -H 'Content-Type: application/json' \
    -d '{"subject": {"type": "user", "id": "bob"}, "resource": {"type": "document", "id": "doc-123"}, "evaluations": [{"action": {"name": "read"}}, {"action": {"name": "delete"}}]}'
{"evaluations":[{"decision":true},{"decision":false}]}
```

## What the server advertises

The PDP metadata (Section 9) lists the endpoints this server serves. The example config sets the three `search` rules, so the search endpoints are listed too:

```console
$ curl -s http://localhost:8181/.well-known/authzen-configuration | jq .
{
  "policy_decision_point": "http://localhost:8181",
  "access_evaluation_endpoint": "http://localhost:8181/access/v1/evaluation",
  "access_evaluations_endpoint": "http://localhost:8181/access/v1/evaluations",
  "search_subject_endpoint": "http://localhost:8181/access/v1/search/subject",
  "search_resource_endpoint": "http://localhost:8181/access/v1/search/resource",
  "search_action_endpoint": "http://localhost:8181/access/v1/search/action"
}
```

Stop the server when you are done:

```sh
kill %1
```

## Verify a release

`checksums.txt` is signed keylessly with cosign by the release workflow, and each image is signed by digest by the image workflow. Releases up to v0.12.1 were signed under `kanywst/opa-authzen-plugin`; [RELEASE.md](https://dyokto.github.io/opa-authzen-plugin/release/#verifying-a-release) has the commands for those.

```console
$ gh release download -R dyokto/opa-authzen-plugin \
    -p checksums.txt -p checksums.txt.sigstore.json -p opa_authzen_linux_amd64
$ cosign verify-blob checksums.txt \
    --bundle checksums.txt.sigstore.json \
    --certificate-identity-regexp '^https://github\.com/dyokto/opa-authzen-plugin/\.github/workflows/post-tag\.yaml@refs/tags/v' \
    --certificate-oidc-issuer https://token.actions.githubusercontent.com
Verified OK
$ sha256sum --check --ignore-missing checksums.txt
opa_authzen_linux_amd64: OK
$ cosign verify ghcr.io/dyokto/opa-authzen-plugin:0.13.0 \
    --certificate-identity-regexp '^https://github\.com/dyokto/opa-authzen-plugin/\.github/workflows/publish\.yaml@refs/tags/v' \
    --certificate-oidc-issuer https://token.actions.githubusercontent.com > /dev/null

Verification for ghcr.io/dyokto/opa-authzen-plugin:0.13.0 --
The following checks were performed on each of these signatures:
  - The cosign claims were validated
  - Existence of the claims in the transparency log was verified offline
  - The code-signing certificate was verified using trusted certificate authority certificates
```

The image also carries a BuildKit SPDX SBOM and SLSA provenance, and the release carries `opa_authzen_sbom.spdx.json` for the source module.

## Next

- [Configuration](https://dyokto.github.io/opa-authzen-plugin/configuration/): every `plugins.authzen` key, obligations, the Access Request and Approval profile, and decision logs
- [API reference](https://dyokto.github.io/opa-authzen-plugin/api/): request and response shapes for each endpoint, including search
- [API gateway integration](https://dyokto.github.io/opa-authzen-plugin/gateways/): Envoy in front of the PDP
- [Examples](https://dyokto.github.io/opa-authzen-plugin/examples/): ABAC, the AuthZEN interop Todo scenario, and Kubernetes
