MCPcopy Index your code
hub / github.com/open-policy-agent/opa

github.com/open-policy-agent/opa @v1.18.2 sqlite

repository ↗ · DeepWiki ↗ · release v1.18.2 ↗
12,647 symbols 72,756 edges 1,110 files 4,517 documented · 36% 10 cross-repo links
README

logo Open Policy Agent

Build Status Go Report Card CII Best Practices Netlify Status

Open Policy Agent (OPA) is an open source, general-purpose policy engine that enables unified, context-aware policy enforcement across the entire stack.

OPA is proud to be a graduated project in the Cloud Native Computing Foundation (CNCF) landscape. For details read the CNCF announcement.

Get started with OPA

  • Write your first Rego policy with the Rego Playground or use it to share your work with others for feedback and support. Have a look at the Access Control examples if you're not sure where to start.
  • Install the VS Code extension to get started locally with live diagnostics, debugging and formatting. See Editor and IDE Support for other supported editors.
  • Go to the OPA Documentation to learn about the Rego language as well as how to deploy and integrate OPA.
  • Check out the learning resources in the Learning Rego section of the ecosystem directory.
  • Follow the Running OPA instructions to get started with the OPA CLI locally.
  • See Docker Hub for container images and the GitHub releases for binaries.
  • Check out the OPA Roadmap to see a high-level snapshot of OPA features in-progress and planned.

Want to talk about OPA or get support?

  • Join the OPA Slack to talk to other OPA users and maintainers. See #help for support.
  • Check out the Community Discussions to ask questions.
  • See the Support page for commercial support options.

Interested to learn what others are doing with OPA?

  • Browse community projects on the OPA Ecosystem Directory - don't forget to list your own!
  • Check out the ADOPTERS.md file for a list of production adopters. Does your organization use OPA in production? Support the OPA project by submitting a PR to add your organization to the list with a short description of your OPA use cases!

Want to integrate OPA?

  • See the high-level Go SDK or the low-level Go API GoDoc to integrate OPA with services written in Go.
  • See the REST API reference to integrate OPA with services written in other languages.
  • See the integration docs for more options.

Want to contribute to OPA?

How does OPA work?

OPA gives you a high-level declarative language to author and enforce policies across your stack.

With OPA, you define rules that govern how your system should behave. These rules exist to answer questions like:

  • Can user X call operation Y on resource Z?
  • What clusters should workload W be deployed to?
  • What tags must be set on resource R before it's created?

You integrate services with OPA so that these kinds of policy decisions do not have to be hardcoded in your service. Services integrate with OPA by executing queries when policy decisions are needed.

When you query OPA for a policy decision, OPA evaluates the rules and data (which you give it) to produce an answer. The policy decision is sent back as the result of the query.

For example, in a simple API authorization use case:

  • You write rules that allow (or deny) access to your service APIs.
  • Your service queries OPA when it receives API requests.
  • OPA returns allow (or deny) decisions to your service.
  • Your service enforces the decisions by accepting or rejecting requests accordingly.

For concrete examples of how to integrate OPA with systems like Kubernetes, Terraform, Docker, SSH, and more, see openpolicyagent.org.

Presentations

  • Open Policy Agent (OPA) Intro & Deep Dive @ Kubecon EU 2026: video
  • Open Policy Agent (OPA) Intro & Deep Dive @ Kubecon NA 2025: video
  • Open Policy Agent (OPA) Intro & Deep Dive @ Kubecon EU 2025: video
  • Open Policy Agent (OPA) Intro & Deep Dive @ Kubecon NA 2024: video
  • Open Policy Agent (OPA) Intro & Deep Dive @ Kubecon EU 2024: video
  • Open Policy Agent (OPA) Intro & Deep Dive @ Kubecon NA 2023: video
  • Open Policy Agent (OPA) Intro & Deep Dive @ Kubecon EU 2023: video
  • Running Policy in Hard to Reach Places with WASM & OPA @ CN Wasm Day EU 2023: video
  • OPA maintainers talk @ Kubecon NA 2022: video
  • Open Policy Agent (OPA) Intro & Deep Dive @ Kubecon EU 2022: video
  • Open Policy Agent Intro @ KubeCon EU 2021: Video
  • Using Open Policy Agent to Meet Evolving Policy Requirements @ KubeCon NA 2020: video
  • Applying Policy Throughout The Application Lifecycle with Open Policy Agent @ CloudNativeCon 2019: video
  • Open Policy Agent Introduction @ CloudNativeCon EU 2018: video, slides
  • Rego Deep Dive @ CloudNativeCon EU 2018: video, slides
  • How Netflix Is Solving Authorization Across Their Cloud @ CloudNativeCon US 2017: video, slides.
  • Policy-based Resource Placement in Kubernetes Federation @ LinuxCon Beijing 2017: slides, screencast
  • Enforcing Bespoke Policies In Kubernetes @ KubeCon US 2017: video, slides
  • Istio's Mixer: Policy Enforcement with Custom Adapters @ CloudNativeCon US 2017: video, slides

Security

A third party security audit was performed by Cure53, you can see the full report here.

Please report vulnerabilities by email to open-policy-agent-security. We will send a confirmation message to acknowledge that we have received the report and then we will send additional messages to follow up once the issue has been investigated.

Extension points exported contracts — how you extend this code

Instruction (Interface)
Instruction represents a single WASM instruction. [13 implementers]
internal/wasm/instruction/instruction.go
Engine (Interface)
Engine repesents a factory for instances of EvalEngine implementations [11 implementers]
internal/rego/opa/engine.go
FormatChecker (Interface)
FormatChecker is the interface all formatters added to FormatCheckerChain must implement [20 implementers]
internal/gojsonschema/format_checkers.go
Type (Interface)
Type represents a type of a term in the language. [10 implementers]
v1/types/types.go
ErrorDetails (Interface)
ErrorDetails interface is satisfied by an error that provides further details. [9 implementers]
v1/rego/errors.go
BaseCache (Interface)
BaseCache defines the interface for a cache that stores cached base documents, i.e. data. [12 implementers]
v1/topdown/cache.go
Transaction (Interface)
Transaction defines the interface that identifies a consistent snapshot over the policy engine's storage layer. [6 implementers]
v1/storage/interface.go
Value (Interface)
Value declares the common interface for all Term values. Every kind of Term value in the language is represented as a ty [11 …
v1/ast/term.go

Core symbols most depended-on inside this repo

Errorf
called by 1861
v1/storage/disk/disk.go
Run
called by 1398
v1/topdown/eval.go
Error
called by 1101
v1/logging/logging.go
Context
called by 1087
internal/gojsonschema/result.go
StringTerm
called by 1042
v1/ast/term.go
VarTerm
called by 942
v1/ast/term.go
New
called by 857
v1/plugins/plugins.go
Equal
called by 711
v1/debug/frame.go

Shape

Function 6,663
Method 4,407
Struct 1,220
TypeAlias 156
Interface 125
FuncType 76

Languages

Go99%
TypeScript1%

Modules by API surface

v1/ast/compile.go376 symbols
v1/ast/term.go360 symbols
v1/rego/rego.go209 symbols
v1/topdown/eval.go204 symbols
v1/ast/policy.go200 symbols
v1/server/server_test.go155 symbols
v1/server/server.go144 symbols
v1/ast/compile_test.go137 symbols
v1/ast/parser.go125 symbols
v1/ast/parser_test.go122 symbols
v1/types/types.go119 symbols
v1/plugins/plugins.go118 symbols

Dependencies from manifests, versioned

dario.cat/mergov1.0.2 · 1×
filippo.io/edwards25519v1.2.0 · 1×
github.com/Azure/go-ansitermv0.0.0-2025010203350 · 1×
github.com/KimMachineGun/automemlimitv0.7.5 · 1×
github.com/Microsoft/go-winiov0.6.2 · 1×
github.com/agnivade/levenshteinv1.2.1 · 1×
github.com/beorn7/perksv1.0.1 · 1×
github.com/bufbuild/protocompilev0.14.1 · 1×
github.com/bytecodealliance/wasmtime-go/v44v44.0.0 · 1×
github.com/cespare/xxhash/v2v2.3.0 · 1×

Datastores touched

dummyDatabase · 1 repos
(mysql)Database · 1 repos
ocpdbDatabase · 1 repos
opactlDatabase · 1 repos
testdbDatabase · 1 repos

For agents

$ claude mcp add opa \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact