TOOL WIKI · SECURITY & IDENTITY
Open Policy Agent
Evaluates application policies using structured input and policy definitions.
Jump to a section 10 sections
EXAMPLE USE CASE
Authorize a same-tenant read while denying other actions
An agent application needs independently enforced input, identity, data or action checks before exposing a protected capability.
- Input
- Trusted principal/resource attributes and the orders:read action.
- Expected output
- A true or false policy decision from the Rego rule.
- Success check: The same-tenant read evaluates to true. A write, different tenant, or missing role evaluates to false.
- Try a failure: Change action to write, remove the role or change tenant; each should deny.
Example scope: Actual local policy evaluation; the application must supply verified identity and resource ownership.
Official reference · Open Policy Agent
Identify the actor, operation, resource, and relevant evidence.
Centralizing decisions about allowed resources and operations. The calling service must enforce the returned policy decision.
Consume the identity, policy result, credential, or detection from this component. Fail according to an explicit application policy.
The business service still checks permission for the actual target resource.
Record the result without leaking unnecessary credentials or sensitive content.
outputTo 06 · Audit + reviewRetain actor, policy version, operation identifier, and result with deliberate redaction.
Result or stopping point
Centralizing decisions about allowed resources and operations. The calling service must enforce the returned policy decision.
When to consider it
- Centralizing decisions about allowed resources and operations.
A design decision to make
- The calling service must enforce the returned policy decision.
Prerequisites and setup
- Docker. Save the two files before running the policy query.
mkdir -p opa-demoTry a small integration
opa-demo/policy.rego
package agent
import rego.v1
default allow := false
allow if {
input.action == "orders:read"
input.principal.role == "support"
input.principal.tenant == input.resource.tenant
}opa-demo/input.json
{"action":"orders:read","principal":{"role":"support","tenant":"a"},"resource":{"tenant":"a","id":"A104"}}Run and check the result
docker run --rm -v "$PWD/opa-demo:/work:ro" openpolicyagent/opa:1 \
eval --format=pretty -d /work/policy.rego -i /work/input.json data.agent.allow- The same-tenant read evaluates to true. A write, different tenant, or missing role evaluates to false.
- The principal/resource in this local fixture stand in for trusted authentication and database state.
Common failures
- Do not continue a protected operation when the policy response is missing, invalid or unavailable.
- A successful test on one fixture is not a complete security evaluation; include bypass attempts and legitimate requests.
Production decisions
- Enforce decisions in application/service code before an operation. A detector score or valid schema is not user authorization.
- Test allowed, denied, malformed, timeout and unavailable outcomes; record redacted decision reasons and default to a safe failure state.
- Sign/version policy bundles and monitor decision latency and policy rollout. Never let the model self-assert the principal role.
Keep exploring
Explore the same layer
Compare candidates on your own workload. This entry describes a product’s role; it is not a claim that products in the category are interchangeable.