Skip to content

API reference

Markdown · llms.txt

The plugin serves these endpoints on OPA's own HTTP server (:8181 by default). The quick start calls the evaluation endpoints against the policy in example/.

Single access evaluation. Request body:

{
"subject": {"type": "user", "id": "alice@example.com"},
"action": {"name": "can_read"},
"resource": {"type": "account", "id": "123"},
"context": {"time": "2024-10-26T01:22-07:00"}
}

Response: {"decision": true}

Batch access evaluations with default value merging and evaluation semantics. See example/ for detailed usage.

A request that carries one or more evaluations is answered with {"evaluations": [...]}, one Decision per request item in the same order. A request whose evaluations array is absent or empty is a single Access Evaluation (spec Section 7.1), and is answered with the singular {"decision": ...} — not a one-element batch envelope.

Send a batch evaluation request, for example to the server started in the quick start:

Terminal window
curl -s -X POST http://localhost:8181/access/v1/evaluations \
-H "Content-Type: application/json" \
-d '{
"subject": {"type": "user", "id": "alice", "properties": {"role": "admin"}},
"action": {"name": "read"},
"evaluations": [
{"resource": {"type": "document", "id": "doc-1"}},
{"resource": {"type": "document", "id": "doc-2"}},
{"action": {"name": "delete"}, "resource": {"type": "document", "id": "doc-3"}}
]
}'

The response should be:

{"evaluations":[{"decision":true},{"decision":true},{"decision":true}]}

Top-level subject, action, resource, and context serve as defaults for each item in the evaluations array. Individual items can override any of these fields. See Section 7 of the AuthZEN spec for details on evaluation semantics (execute_all, deny_on_first_deny, permit_on_first_permit).

Use evaluation semantics to short-circuit batch processing:

Terminal window
curl -s -X POST http://localhost:8181/access/v1/evaluations \
-H "Content-Type: application/json" \
-d '{
"subject": {"type": "user", "id": "bob"},
"action": {"name": "read"},
"options": {"evaluations_semantic": "permit_on_first_permit"},
"evaluations": [
{"resource": {"type": "document", "id": "doc-1"}},
{"resource": {"type": "document", "id": "doc-2"}}
]
}'

Subject Search (spec Section 8.4). Requires search.subject to be configured. Request body:

{
"subject": {"type": "user"},
"action": {"name": "can_read"},
"resource": {"type": "account", "id": "123"},
"page": {"limit": 100}
}

Response:

{
"page": {"next_token": "", "count": 2, "total": 2},
"results": [
{"type": "user", "id": "alice@example.com"},
{"type": "user", "id": "bob@example.com"}
]
}

Resource Search (spec Section 8.5). Requires search.resource. Same response shape as Subject Search; results are resource entities.

Action Search (spec Section 8.6). Requires search.action. Request omits the action key. results are action entities of shape {"name": "..."}.

PDP metadata discovery endpoint (Section 9).

Terminal window
curl -s http://localhost:8181/.well-known/authzen-configuration | jq .

Response, with no search rules configured:

{
"policy_decision_point": "http://localhost:8181",
"access_evaluation_endpoint": "http://localhost:8181/access/v1/evaluation",
"access_evaluations_endpoint": "http://localhost:8181/access/v1/evaluations"
}