Skip to content

Quick start

Markdown · 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.

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.

Terminal window
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.

Terminal window
docker pull ghcr.io/dyokto/opa-authzen-plugin:0.13.0

The image's entrypoint is the plugin binary. In 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.

Terminal window
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.

Terminal window
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:

Terminal window
$ opa-authzen-plugin version
Version: 1.23.0
...

The policy and config are example/policy.rego and example/config.yaml.

Terminal window
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:

plugins:
authzen:
path: "authzen"
decision: "allow"

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.

Terminal window
$ 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

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

Terminal window
$ 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 first rule in the policy allows any action for a subject with the admin role:

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:

Terminal window
$ 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 without subject, action or resource is rejected with 400 before the policy is evaluated:

Terminal window
$ 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

/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:

Terminal window
$ 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}]}

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:

Terminal window
$ 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:

Terminal window
kill %1

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 has the commands for those.

Terminal window
$ 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.

  • Configuration: every plugins.authzen key, obligations, the Access Request and Approval profile, and decision logs
  • API reference: request and response shapes for each endpoint, including search
  • API gateway integration: Envoy in front of the PDP
  • Examples: ABAC, the AuthZEN interop Todo scenario, and Kubernetes