Explore our new Cybersecurity Terms Glossary, explained by our experts.

View the Glossary View the Glossary
PRIVIA

Cybersecurity Terms Glossary

What Is Open Policy Agent?

Open Policy Agent is a general-purpose policy engine that separates authorisation decisions from application code. Policies are written in Rego and return JSON answers to JSON questions.

Illustration for the cybersecurity term Open Policy Agent
Home / Blog / Cybersecurity Terms / What Is Open Policy Agent?
17 November 2026

What Is Open Policy Agent?

What Is Open Policy Agent?

Open Policy Agent, usually shortened to OPA, is a policy engine that answers one kind of question: given this input, what does policy say? You hand it a JSON document describing a request, it evaluates the rules you have loaded, and it returns a JSON decision. What that decision means — allow the API call, reject the Terraform plan, filter these rows, admit this pod — is entirely up to the system that asked.

It was created at Styra by Tim Hinrichs and Torin Sandall in 2016, donated to the Cloud Native Computing Foundation, and graduated there in 2021.

Decoupling Policy From Code

The problem OPA addresses is familiar in any system that has grown for a few years. Authorisation logic ends up scattered across services, written differently in each language, impossible to audit centrally, and requiring a deployment to change. Moving those rules into a dedicated engine makes them reviewable, testable, and changeable without touching the applications.

Evaluation uses two documents. input is the question — the request, the user, the resource. data is the context the engine already holds: role mappings, approved regions, a list of exempt accounts, pushed in by whatever system owns that information.

Rego

Policies are written in Rego, a declarative language derived from Datalog. It reads oddly at first because rules are defined by what makes them true, not by a sequence of steps:

package authz

default allow := false

allow if {
    input.method == "GET"
    input.path[0] == "reports"
    input.user.roles[_] == "analyst"
}

allow if {
    input.user.roles[_] == "admin"
}

Several rules with the same name are alternatives: the decision is true if any of them holds. The underscore iterates over a collection. A default makes the deny-by-default behaviour explicit, and omitting it is one of the most common ways a policy ends up weaker than intended. OPA 1.0, released at the start of 2025, made the newer Rego syntax with if and contains the default, so older examples found online may need adjusting.

Rego ships with a built-in test framework. A policy without tests is a liability, because the failure mode of an authorisation rule is silent over-permission.

Where People Actually Run It

Deployment is flexible: a daemon exposing a REST API, a Go library embedded in your service, or a policy compiled to WebAssembly and evaluated in-process. The daemon is the common choice because it keeps policy distribution separate from application releases.

Distribution and Evidence

Two features matter for anyone who will be audited. The bundle API lets OPA pull signed policy and data archives from an object store or registry on an interval, so updating a rule across a hundred instances is a publish rather than a deployment. Decision logs stream every evaluation, with its input and result, to a collector.

Those logs are unusually useful evidence. For ISO 27001 or a customer security review, being able to show every access decision for a six-month period, with the policy version that produced it, is a stronger answer than a document describing intended behaviour. It is also a privacy consideration: decision inputs often contain personal data, so apply retention limits and the same protections you would give any other log under UK GDPR.

Honest Trade-Offs

Rego is genuinely hard for the first fortnight, and teams underestimate this. Evaluation adds latency to every request that consults it, which is manageable with a sidecar and unacceptable over a wide-area network. Centralised policy also creates a central failure point — decide what happens when OPA is unreachable, and make that choice explicit rather than discovering it during an incident.

Used well, it turns scattered conditional logic into policy as code that can be reviewed, versioned, tested, and proven.

FAQ – Frequently Asked Questions

Is Open Policy Agent Only for Kubernetes?

No, although Kubernetes admission control through Gatekeeper is how most teams first encounter it. OPA is a general engine: it authorises API calls, gates Terraform plans, filters database queries, enforces rules in continuous integration, and makes decisions for Envoy and Kafka. Anywhere a system needs to ask whether something is permitted and can express the question as JSON, OPA can answer it.

What Is the Difference Between OPA and Gatekeeper?

OPA is the engine and Rego is its language. Gatekeeper is a Kubernetes-specific project that packages OPA as an admission controller, adds constraint templates and constraints as Kubernetes resources, provides an audit loop over existing objects, and manages the webhook. You can run bare OPA as an admission controller, but Gatekeeper handles the operational detail that makes it workable.

How Do I Test Rego Policies?

OPA includes a test framework. Write rules in files whose names begin with test_ in the same package, assert the expected decision for a given input, and run opa test with coverage reporting. Treat authorisation policies like any other security-critical code: tests for the allow cases, tests for the deny cases, and a test that proves the default denies when no rule matches.

Does OPA Slow Down Requests?

It adds latency proportional to policy complexity and the size of the data it must search. A simple policy evaluated by a local sidecar typically costs single-digit milliseconds, which most applications absorb easily. Problems appear when policies iterate over large replicated datasets or when the engine is called across a network. Benchmark with production-sized data before committing to an inline authorisation path.

Related Terms

You May Be Interested In These

What Are Canary Accounts?

Cybersecurity Terms

17 November 2026

What Are Canary Accounts?

Read More
What Is Cloud Incident Response Readiness?

Cybersecurity Terms

17 November 2026

What Is Cloud Incident Response Readiness?

Read More