Skip to content

Cedar vs Rego vs OpenFGA: Policy Language Comparison

A deep comparison of Cedar, Rego, OpenFGA DSL, and Cerbos YAML/CEL policy languages: syntax, performance, formal verification, tooling, and TypeScript integration.

Ayhan Sipahi Ayhan Sipahi

The policy language you choose for authorization shapes the rest of your security architecture: it decides how policies are written, tested, deployed, and audited. Switching later means rewriting all of them, so the choice is worth making deliberately.

Four languages cover most of the field: Cedar, Rego, OpenFGA DSL, and Cerbos YAML/CEL. Two of them work as defaults. When access is fundamentally about relationships (“who has what relationship to what”), OpenFGA DSL is the starting point. When it is about attributes and you want machine-checked guarantees over the whole policy set, Cedar is. Rego and Cerbos answer narrower constraints: one language across infrastructure and application policy, or the shortest path to policies running in production.

Note

This is Part 4 of the External Authorization Systems series. The main post covers platform selection and architecture patterns.

Why Policy Language Matters#

Authorization logic is security-critical code. When it lives scattered across application services as if-else statements and middleware checks, it becomes impossible to audit, test comprehensively, or reason about. Separating policy from code addresses this directly.

Separation of Policy from Code#

A dedicated policy language creates a clear boundary: application code describes what the user wants to do, and the policy engine decides whether they can. This separation means:

  • Security teams can review policies without reading application code
  • Policy changes deploy independently from application releases
  • Audit trails capture policy decisions in a standardized format
  • Policy testing becomes systematic rather than scattered across integration tests

Auditability and Compliance#

SOC 2, HIPAA, and GDPR audits require demonstrable access control. When policies are expressed in a dedicated language and stored in version control, auditors can review the complete authorization logic for a system without understanding the underlying application code. This is a meaningful advantage over authorization logic embedded in application code.

Formal Verification#

Cedar ships with Cedar Analyzer, first-party tooling for authorization-focused property analysis and formal reasoning over policy sets (for example, proving that no policy grants access unless the principal meets a condition). Other ecosystems apply formal methods too, but among widely used authorization policy languages, a maintained analyzer at this scope is uncommon. The guarantees are different in kind from exhaustive testing alone.

Cedar (AWS)#

Cedar is a declarative policy language developed by Amazon and used by AWS Verified Permissions. It was designed from the ground up for authorization, with formal verification as a core design goal.

Syntax and Model#

Cedar uses a permit/forbid model. Every policy either permits or forbids an action. If any forbid policy matches a request, the request is denied regardless of how many permit policies also match. The language semantics carry this “deny overrides” behavior, so applications never have to enforce it by convention.

// Permit editors to edit documents in their department
permit(
  principal in Role::"Editor",
  action == Action::"EditDocument",
  resource
)
when {
  principal.department == resource.department
};

// Forbid all access outside business hours -- overrides any permit
forbid(
  principal,
  action,
  resource
)
when {
  context.currentTime.hour < 9 ||
  context.currentTime.hour >= 17
};

Key characteristics of Cedar:

  • Entity types and schema: Cedar requires a typed schema defining entity types, their attributes, and relationships. The is operator (Cedar language 3.0+, RFC 5 (opens in new tab)) enables type-based matching within policies.
  • Permit/forbid model: Explicit deny overrides. This makes reasoning about policy outcomes predictable.
  • Conditions with when and unless: Boolean conditions that reference principal, resource, action, and context attributes.
  • No side effects: Cedar policies are pure functions. They cannot modify state, call external services, or produce side effects. This is what makes formal verification possible.

Formal Verification#

Cedar Analyzer can answer questions like:

  • “Is it possible for a non-admin to delete a production resource?”
  • “Do any two policies in this policy store conflict?”
  • “Does every permitted action require the principal to belong to at least one group?”

Each answer is a mathematical proof over the entire policy space. The verification is implemented using automated reasoning (SMT solvers) and covers the whole policy set at once, which is a different guarantee from running a fixture through an evaluator.

Performance#

Cedar is written in Rust and compiles policies to an efficient internal representation. The Cedar team’s OOPSLA 2024 paper measured the Cedar authorizer at 28.7x-35.2x faster than OpenFGA and 42.8x-80.8x faster than Rego on randomly generated inputs for three example applications. These are the language authors’ own measurements.

An important qualification: these benchmarks compare fundamentally different operations. Cedar evaluates local attribute-based policies against a request. OpenFGA traverses a relationship graph. Rego evaluates Datalog-style queries over a document model. Comparing their raw evaluation speed is like comparing the speed of a SQL query to a graph traversal; the architectures solve different problems. Cedar’s speed advantage is real for ABAC workloads, but it does not mean Cedar is “better” than OpenFGA for relationship-based access control.

Integration with AWS Verified Permissions#

Cedar is the native policy language of AWS Verified Permissions (AVP), and it also runs outside AWS through the open-source Cedar SDK. The main post separates the language choice from the managed service.

Rego (OPA)#

Rego is the policy language for Open Policy Agent (OPA), a CNCF graduated project. Unlike Cedar’s authorization-specific design, Rego is a general-purpose policy language that can express authorization rules, Kubernetes admission control, Terraform plan validation, and infrastructure compliance checks.

Syntax and Model#

Rego is inspired by Datalog, a declarative logic programming language. Policies are expressed as rules that evaluate to true or false. The input document contains the request context, and data contains external data loaded into OPA.

package document.authz

default allow := false

# Allow editors to edit documents in their department
allow if {
  input.user.role == "editor"
  input.user.department == input.resource.department
  is_business_hours
}

# Helper rule for business hours check (the caller sends the time, UTC)
is_business_hours if {
  hour := time.clock([time.parse_rfc3339_ns(input.now), "UTC"])[0]
  hour >= 9
  hour < 17
}

# Deny overrides -- must be checked separately
deny if {
  input.resource.classification == "restricted"
  not input.user.clearance == "top-secret"
}

Key characteristics of Rego:

  • Datalog-inspired: Rules are implicitly AND-joined (all conditions in a rule body must be true). Multiple rule definitions with the same name are OR-joined.
  • Document model: Input and data are JSON documents. Policies navigate these documents using path expressions.
  • General-purpose: Rego expresses infrastructure, admission control, and compliance policy alongside authorization. This flexibility comes at the cost of a steeper learning curve.
  • Partial evaluation: OPA can partially evaluate policies, pre-computing results where possible and leaving placeholders for unknown values. This enables efficient query compilation.
  • Built-in functions: Rego includes functions for string manipulation, time operations, HTTP requests, JSON Web Token validation, and more. Two of them reach outside the policy; a section below covers them.

Learning Curve#

Rego’s Datalog roots make it unfamiliar to most application developers. The implicit conjunction (AND) within rule bodies, the implicit disjunction (OR) across rule definitions, and the unification semantics require a different mental model than imperative or even most declarative languages.

Older examples add a second source of confusion. OPA 1.0 made the v1 syntax mandatory: every rule with a body needs if, and every multi-value rule needs contains. Pre-1.0 policies omit those keywords, and OPA 1.x accepts them only in its v0 compatibility mode. Other examples carry import rego.v1, the opt-in that let pre-1.0 versions enforce the same rules early. OPA 1.x no longer needs that import, so the examples here leave it out.

Built-ins That Reach Outside the Policy#

Cedar policies cannot call anything outside the request. Rego has no such boundary. http.send performs an HTTP request during evaluation, and time.now_ns reads the wall clock. Either one makes the decision depend on data the input does not contain. The same input can then produce different decisions, which weakens analysis and ties test results to the moment and network the suite runs in. The OPA documentation says http.send must not be used to change external systems, but the language itself does not stop a policy from doing so.

OPA can block these built-ins at build time. A capabilities file lists the built-in functions that policies may depend on, and opa check and opa build return an error when a policy needs a built-in missing from the list. Leaving http.send out rejects every policy that calls it; the allow_net capability narrows its reach to named hosts. For application authorization, a capabilities file without http.send, plus a clock passed in input (as in the Testing examples), keeps Rego close to Cedar’s model: everything the decision needs arrives with the request or in data.

The OPA/Styra Situation#

Apple acqui-hired Styra’s co-founders and core team, and Styra DAS (the commercial OPA management platform) is moving to community-maintained open source while OPA stays under CNCF governance. The main post covers what that means for teams that relied on Styra DAS.

Ecosystem Strength#

Despite the Styra transition, Rego has the broadest ecosystem of any policy language:

  • Kubernetes: OPA Gatekeeper for admission control
  • Terraform: Conftest and Rego policies for plan validation
  • Envoy: OPA as an external authorization filter
  • API gateways: Kong, Traefik, and others support OPA integration
  • CI/CD: Policy checks in build pipelines

This ecosystem breadth is Rego’s strongest advantage. If you need a single policy language across infrastructure and application authorization, Rego is the most versatile choice.

OpenFGA DSL#

OpenFGA DSL is the modeling language for OpenFGA, the open-source Zanzibar-inspired authorization engine behind Okta’s managed Auth0 FGA service. Unlike Cedar and Rego, which express rules, OpenFGA DSL expresses relationships and type definitions.

Syntax and Model#

OpenFGA DSL defines authorization models as type systems. Access is determined by the existence of relationships between entities, not by evaluating conditions against attributes.

model
  schema 1.1

type user

type department
  relations
    define member: [user]

type document
  relations
    define department: [department]
    define owner: [user]
    define editor: [user] or member from department
    define viewer: editor or owner
    define can_edit: editor
    define can_view: viewer

Key characteristics of OpenFGA DSL:

  • Type system: Every entity has a type. Relations are defined between types. This creates a strongly-typed authorization model.
  • Relationship operators: Direct assignment ([user]), computed relations (editor or owner), and tuple-to-userset mappings (member from department).
  • No attribute conditions in the model: The core model expresses structural relationships, and conditional logic lives outside it. This is a deliberate design choice aligned with the Zanzibar paradigm.

Conditions (Schema 1.1+)#

Starting with schema 1.1, OpenFGA added support for conditions using Google’s Common Expression Language (CEL). Conditions can be attached to relationship type restrictions:

model
  schema 1.1

type user

type document
  relations
    define viewer: [user]
    define time_limited_viewer: [user with non_expired_grant]

condition non_expired_grant(current_time: timestamp, grant_expires: timestamp) {
  current_time < grant_expires
}

This is a significant addition, but conditions in OpenFGA attach only to relationship assignments; they do not form a general policy rule language. The business hours check from the example scenario would have to ride along on the relationship as a condition.

Comparison with SpiceDB Schema#

SpiceDB uses a similar but distinct schema language. Both are Zanzibar-inspired, but they differ in syntax and some capabilities:

// SpiceDB schema -- same concepts, different syntax
definition user {}

definition department {
  relation member: user
}

definition document {
  relation department: department
  relation owner: user
  relation editor: user | department#member
  permission can_edit = editor
  permission can_view = editor + owner
}

SpiceDB’s schema uses definition instead of type, permission instead of define, and the + operator for union. SpiceDB also implements the full Zanzibar consistency model with ZedTokens, which OpenFGA does not.

SpiceDB’s counterpart to OpenFGA conditions is caveats: named CEL expressions attached to a relation with with (for example relation editor: user with during_business_hours). Caveat context can be stored on the relationship when it is written or passed with the CheckPermission request, and stored values win when both are present.

When to Use OpenFGA DSL#

OpenFGA DSL excels when authorization is primarily about “who has what relationship to what.” Applications with sharing models (Google Docs-style “User X can edit Document Y”), hierarchical structures (folder permissions inherited by documents), and organizational models (department-based access) map naturally to OpenFGA’s relationship model.

It is less suited for attribute-based conditions. If your authorization rules depend heavily on time, location, risk scores, or other contextual attributes, OpenFGA requires either using conditions (limited) or layering an ABAC system alongside it.

Cerbos (YAML + CEL)#

Cerbos takes a different approach: policies are written in YAML with CEL (Common Expression Language) for conditions. There is no custom language to learn. If you know YAML and basic expression syntax, you can write Cerbos policies.

Syntax and Model#

Cerbos uses a resource-centric model. Policies are attached to resource types and define which roles can perform which actions, optionally with conditions.

# Resource policy for documents
apiVersion: api.cerbos.dev/v1
resourcePolicy:
  resource: "document"
  version: "default"
  rules:
    - actions: ["edit"]
      effect: EFFECT_ALLOW
      roles: ["editor"]
      condition:
        match:
          all:
            of:
              - expr: "request.resource.attr.department == request.principal.attr.department"
              - expr: "now().getHours() >= 9 && now().getHours() < 17"

    - actions: ["delete"]
      effect: EFFECT_ALLOW
      roles: ["admin"]
      # No condition -- admins can always delete

Key characteristics of Cerbos YAML/CEL:

  • Resource-centric: Policies are organized by resource type. Each resource type has its own policy file.
  • YAML structure: The policy structure is declarative YAML. No custom grammar or parser to learn.
  • CEL expressions: Conditions use Google’s Common Expression Language, which is also used by Kubernetes, Firebase, and Google Cloud IAM. CEL is a well-documented, broadly supported expression language.
  • Derived roles: Roles computed at request time based on context. For example, a user with the base role “manager” becomes “department_manager” when the document belongs to their department.

Derived Roles#

Derived roles are a distinctive Cerbos feature. They allow dynamic role computation without requiring the application to pre-compute roles:

# Derived roles definition
apiVersion: "api.cerbos.dev/v1"
derivedRoles:
  name: "document_roles"
  definitions:
    - name: "department_editor"
      parentRoles: ["editor"]
      condition:
        match:
          expr: "request.resource.attr.department == request.principal.attr.department"

    - name: "department_manager"
      parentRoles: ["manager"]
      condition:
        match:
          expr: "request.resource.attr.department == request.principal.attr.department"

A resource policy imports this set with importDerivedRoles and references the roles by name, creating a two-layer system: the application sends base roles (editor, manager), and Cerbos computes the context-specific roles at evaluation time. The scenario below uses exactly these two.

Trade-offs#

The YAML/CEL approach trades expressiveness for accessibility. Cerbos policies are straightforward for developers to read and write without specialized training. Its learning curve is the lowest of the four: the structure is plain YAML, and each condition is a single CEL expression. However, YAML does not support advanced features like Rego’s partial evaluation, Cedar Analyzer-style property analysis, or OpenFGA’s relationship graph traversal. For complex authorization logic, YAML policies can become deeply nested and harder to maintain.

Same Scenario in All Four Languages#

To make the comparison concrete, here is the same authorization rule implemented in all four languages, including edge cases.

The rule: “Editors can edit documents in their department during business hours. Department managers can edit any document in their department at any time. No one can edit archived documents.”

Business hours are 09:00 to 17:00 UTC. Cedar and OpenFGA get the hour from the caller as a context value, and Rego reads an RFC 3339 timestamp from input.now. Cerbos uses now(), the current time on the Cerbos server, which its tests can pin. Four test vectors fix the semantics, and each implementation below returns the same answers for them:

Principal (same department as the document)Document statusTime (UTC)Expected
Editoractive09:30Allow
Editoractive22:00Deny
Department manageractive22:00Allow
Editor or department managerarchived10:00Deny

Cedar#

// Editors: department match + business hours
permit(
  principal in Role::"Editor",
  action == Action::"EditDocument",
  resource
)
when {
  principal.department == resource.department &&
  context.currentTime.hour >= 9 &&
  context.currentTime.hour < 17
};

// Department managers: department match, no time restriction
permit(
  principal in Role::"DepartmentManager",
  action == Action::"EditDocument",
  resource
)
when {
  principal.department == resource.department
};

// Deny override: no one can edit archived documents
forbid(
  principal,
  action == Action::"EditDocument",
  resource
)
when {
  resource.status == "archived"
};

Cedar handles the deny override naturally. The forbid policy for archived documents overrides both permit policies regardless of role or time. The application computes context.currentTime.hour in UTC and sends it with each request.

Rego#

package document.authz

default allow := false

# Editors: department match + business hours
allow if {
  input.user.role == "editor"
  input.user.department == input.resource.department
  is_business_hours
  not is_archived
}

# Department managers: department match, no time restriction
allow if {
  input.user.role == "department_manager"
  input.user.department == input.resource.department
  not is_archived
}

# The caller sends the time; the policy never reads the wall clock
is_business_hours if {
  hour := time.clock([time.parse_rfc3339_ns(input.now), "UTC"])[0]
  hour >= 9
  hour < 17
}

is_archived if {
  input.resource.status == "archived"
}

In Rego, the archived check must be explicitly included in each allow rule (using not is_archived). There is no built-in deny-overrides mechanism; the application must query both allow and any deny rules. time.clock already defaults to UTC for a bare timestamp; the explicit "UTC" argument keeps the zone visible and is the place to name another IANA zone when business hours follow a local clock.

OpenFGA DSL#

model
  schema 1.1

type user

type department
  relations
    define editor: [user with during_business_hours]
    define manager: [user]

type document
  relations
    define department: [department]
    define archived: [user:*]
    define can_edit: (editor from department or manager from department) but not archived

condition during_business_hours(current_hour: int) {
  current_hour >= 9 && current_hour < 17
}

Editor and manager are department roles here, so the department match comes from the graph: editor from department only reaches users who hold the editor relation on the document’s own department. The time check rides on the editor tuple. The application writes user:alice editor department:engineering with the during_business_hours condition and passes current_hour in the context of every check. Manager tuples carry no condition, and a wildcard user:* tuple on archived removes the document from everyone’s can_edit.

This illustrates a fundamental difference: OpenFGA answers “who has what relationship,” and the time-based part only works because the caller supplies the hour as context.

Cerbos YAML/CEL#

apiVersion: api.cerbos.dev/v1
resourcePolicy:
  resource: "document"
  version: "default"
  importDerivedRoles:
    - "document_roles"
  rules:
    # Editors: department match (derived role) + business hours in UTC
    - actions: ["edit"]
      effect: EFFECT_ALLOW
      derivedRoles: ["department_editor"]
      condition:
        match:
          expr: "now().getHours() >= 9 && now().getHours() < 17"

    # Department managers: department match, any time
    - actions: ["edit"]
      effect: EFFECT_ALLOW
      derivedRoles: ["department_manager"]

    # Deny override: archived documents
    - actions: ["edit"]
      effect: EFFECT_DENY
      roles: ["*"]
      condition:
        match:
          expr: "request.resource.attr.status == 'archived'"

Cerbos supports explicit EFFECT_DENY rules that override EFFECT_ALLOW rules, similar to Cedar’s forbid mechanism. The derived roles (department_editor, department_manager) come from the document_roles set in Derived Roles and carry the department match. getHours() without an argument uses UTC; pass a zone, as in getHours("Europe/Berlin"), when business hours follow a local clock.

Performance Benchmarks#

Performance matters for authorization: it sits in the critical path of every API request. But benchmark numbers need careful interpretation.

Raw Numbers#

The Cedar paper (OOPSLA 2024) reports the following on randomly generated inputs for three example applications: two models from the OpenFGA examples (a Google Drive-style app and a GitHub-style app) and Cedar’s own TinyTodo sample:

EngineRelative SpeedArchitecture
Cedar1x (baseline)Local attribute evaluation
OpenFGA28.7-35.2x slowerRelationship graph traversal
Rego (OPA)42.8-80.8x slowerDatalog query evaluation

The Cedar team designed and ran this benchmark. Independent work tests something else: Doyensec’s Security Policy Evaluation Framework (SPEF), funded by Teleport, ran Rego, Cedar, OpenFGA, and Teleport’s own engine against security-focused test cases and reports a pass/fail result per case, with no speed ratios.

Why Direct Comparison Is Misleading#

These engines solve fundamentally different problems:

  • Cedar evaluates a set of policies against a single request with known attributes. The evaluation is stateless and local.
  • OpenFGA traverses a relationship graph to determine if a path exists between a subject and an object. The speed depends on graph depth and breadth.
  • Rego/OPA evaluates Datalog-inspired queries against a document model. Rego’s generality means it does more work per evaluation than a purpose-built authorization evaluator.

Comparing their speeds is like comparing a hash table lookup to a graph BFS to a SQL query. Each is fast for its intended operation.

Real-World Performance Considerations#

In practice, authorization latency depends on more than raw evaluation speed:

  • Network overhead: A sidecar PDP adds microseconds. A centralized PDP adds milliseconds. For most applications, network latency dominates evaluation time.
  • Caching: Caching authorization decisions (with appropriate TTL) reduces the impact of slower evaluation engines. A cached decision is fast regardless of the engine.
  • Batch evaluation: Cedar (via AVP) and Cerbos support batch authorization, checking multiple permissions in a single request. This amortizes network overhead.
  • Relationship graph size: OpenFGA and SpiceDB performance depends on the depth of the relationship graph. Shallow graphs are fast; deeply nested hierarchies require more traversal.

Tip

Benchmark your specific authorization patterns, not generic inputs. A system with 50 ABAC policies will have different performance characteristics than one with 5 million relationships.

Tooling and Developer Experience#

Policy language usability depends on more than syntax. The surrounding tooling (CLI tools, testing frameworks, playgrounds, and IDE support) shapes the day-to-day developer experience.

CLI Tools#

LanguageCLI ToolKey Features
Cedarcedar CLIValidate, evaluate, format, analyze policies
Regoopa CLIEvaluate, test, fmt, build, check policies
OpenFGAfga CLIModel validation, relationship queries, store management
Cerboscerbos CLICompile, test, serve policies locally

Testing#

All four languages support policy testing, but the approaches differ:

Cedar: The Cedar CLI includes a check-parse command and the analysis tools can verify policy properties. Integration testing uses the Cedar SDK to evaluate policies against test fixtures.

Rego: OPA has a built-in testing framework. Tests are written in Rego itself, which is both powerful and adds to the learning curve. These tests cover the four vectors from the scenario, and each one pins input.now, so the result does not depend on when the suite runs:

package document.authz_test

import data.document.authz

editor := {"role": "editor", "department": "engineering"}

manager := {"role": "department_manager", "department": "engineering"}

active_doc := {"department": "engineering", "status": "active"}

archived_doc := {"department": "engineering", "status": "archived"}

test_editor_allowed_at_0930 if {
  authz.allow with input as {"user": editor, "resource": active_doc, "now": "2026-03-23T09:30:00Z"}
}

test_editor_denied_at_2200 if {
  not authz.allow with input as {"user": editor, "resource": active_doc, "now": "2026-03-23T22:00:00Z"}
}

test_manager_allowed_at_2200 if {
  authz.allow with input as {"user": manager, "resource": active_doc, "now": "2026-03-23T22:00:00Z"}
}

test_archived_denied_for_editor_and_manager if {
  not authz.allow with input as {"user": editor, "resource": archived_doc, "now": "2026-03-23T10:00:00Z"}
  not authz.allow with input as {"user": manager, "resource": archived_doc, "now": "2026-03-23T10:00:00Z"}
}

OpenFGA: OpenFGA provides model validation and assertion testing through the CLI and the playground. Tests verify that specific relationships produce expected authorization outcomes.

Cerbos: Cerbos has a dedicated test framework using YAML test files (named *_test.yaml). Principals and resources are fixtures referenced by key, and options.now sets the value now() returns, which makes the business hours rule testable:

# document_test.yaml
name: DocumentEditTestSuite
principals:
  editor:
    id: "editor1"
    roles: ["editor"]
    attr:
      department: "engineering"
  manager:
    id: "manager1"
    roles: ["manager"]
    attr:
      department: "engineering"
resources:
  active_doc:
    kind: "document"
    id: "doc1"
    attr:
      department: "engineering"
      status: "active"
  archived_doc:
    kind: "document"
    id: "doc2"
    attr:
      department: "engineering"
      status: "archived"
tests:
  - name: Editor inside business hours
    options:
      now: "2026-03-23T09:30:00Z"
    input:
      principals: ["editor"]
      resources: ["active_doc"]
      actions: ["edit"]
    expected:
      - principal: editor
        resource: active_doc
        actions:
          edit: EFFECT_ALLOW
  - name: Editor outside business hours
    options:
      now: "2026-03-23T22:00:00Z"
    input:
      principals: ["editor"]
      resources: ["active_doc"]
      actions: ["edit"]
    expected:
      - principal: editor
        resource: active_doc
        actions:
          edit: EFFECT_DENY
  - name: Manager outside business hours
    options:
      now: "2026-03-23T22:00:00Z"
    input:
      principals: ["manager"]
      resources: ["active_doc"]
      actions: ["edit"]
    expected:
      - principal: manager
        resource: active_doc
        actions:
          edit: EFFECT_ALLOW
  - name: Archived document
    options:
      now: "2026-03-23T10:00:00Z"
    input:
      principals: ["editor", "manager"]
      resources: ["archived_doc"]
      actions: ["edit"]
    expected:
      - principal: editor
        resource: archived_doc
        actions:
          edit: EFFECT_DENY
      - principal: manager
        resource: archived_doc
        actions:
          edit: EFFECT_DENY

Playground and IDE Support#

LanguagePlaygroundVS Code ExtensionIntelliJ Plugin
Cedarcedarpolicy.com (opens in new tab)YesNo
Regoplay.openpolicyagent.org (opens in new tab)Yes (OPA extension)Yes
OpenFGAplay.fga.dev (opens in new tab)YesYes
Cerbosplay.cerbos.dev (opens in new tab)YesNo

Documentation Quality#

  • Cedar: Well-structured reference documentation. The academic paper (OOPSLA 2024) provides deep technical background but is not required for practical use.
  • Rego: Extensive documentation, but the volume can be overwhelming. The learning path from beginner to proficient is not always clear.
  • OpenFGA: Clear, example-driven documentation with step-by-step modeling guides. The playground integration makes concepts tangible.
  • Cerbos: Practical, developer-oriented documentation with progressive tutorials and migration guides from OPA.

Integration Patterns#

How each language integrates with application code matters for adoption and maintenance. Here are TypeScript integration examples for each, wired to the scenario above. Each call sends what its policy needs. Cedar and Rego get the role, the department, the document status and the time. Cerbos gets the same attributes and reads the time on the server. OpenFGA gets only the hour, because the role, department and archived status live in stored tuples.

Cedar (via AWS Verified Permissions)#

import {
  VerifiedPermissionsClient,
  IsAuthorizedCommand,
} from "@aws-sdk/client-verifiedpermissions";

const avpClient = new VerifiedPermissionsClient({ region: "eu-central-1" });

async function canEditDocument(
  userId: string,
  userRole: string, // "Editor" or "DepartmentManager"
  userDept: string,
  documentId: string,
  docDept: string,
  docStatus: string
): Promise<boolean> {
  const command = new IsAuthorizedCommand({
    policyStoreId: "ps-store-id",
    principal: { entityType: "User", entityId: userId },
    action: { actionType: "Action", actionId: "EditDocument" },
    resource: { entityType: "Document", entityId: documentId },
    context: {
      contextMap: {
        // Business hours are evaluated in UTC
        currentTime: { record: { hour: { long: new Date().getUTCHours() } } },
      },
    },
    entities: {
      entityList: [
        {
          identifier: { entityType: "User", entityId: userId },
          attributes: { department: { string: userDept } },
          parents: [{ entityType: "Role", entityId: userRole }],
        },
        {
          identifier: { entityType: "Document", entityId: documentId },
          attributes: {
            department: { string: docDept },
            status: { string: docStatus },
          },
        },
      ],
    },
  });

  const response = await avpClient.send(command);
  return response.decision === "ALLOW";
}

Rego (via OPA REST API)#

async function canEditDocument(
  userId: string,
  userRole: string, // "editor" or "department_manager"
  userDept: string,
  documentId: string,
  docDept: string,
  docStatus: string
): Promise<boolean> {
  const response = await fetch("http://localhost:8181/v1/data/document/authz/allow", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      input: {
        user: { id: userId, role: userRole, department: userDept },
        resource: { id: documentId, department: docDept, status: docStatus },
        now: new Date().toISOString(), // RFC 3339, UTC
      },
    }),
  });

  const result = await response.json();
  return result.result === true;
}

OpenFGA (via SDK)#

import { OpenFgaClient } from "@openfga/sdk";

const fgaClient = new OpenFgaClient({
  apiUrl: "http://localhost:8080",
  storeId: "store-id",
  authorizationModelId: "model-id",
});

async function canEditDocument(
  userId: string,
  documentId: string
): Promise<boolean> {
  const { allowed } = await fgaClient.check({
    user: `user:${userId}`,
    relation: "can_edit",
    object: `document:${documentId}`,
    context: { current_hour: new Date().getUTCHours() },
  });

  return allowed ?? false;
}

// Write a relationship (department editor, valid during business hours)
async function assignDepartmentEditor(
  userId: string,
  departmentId: string
): Promise<void> {
  await fgaClient.write({
    writes: [
      {
        user: `user:${userId}`,
        relation: "editor",
        object: `department:${departmentId}`,
        condition: { name: "during_business_hours" },
      },
    ],
  });
}

Cerbos (via SDK)#

import { GRPC as Cerbos } from "@cerbos/grpc";

const cerbos = new Cerbos("localhost:3593");

async function canEditDocument(
  userId: string,
  documentId: string,
  userRoles: string[], // base roles, e.g. ["editor"] or ["manager"]
  userDept: string,
  docDept: string,
  docStatus: string
): Promise<boolean> {
  const decision = await cerbos.checkResource({
    principal: {
      id: userId,
      roles: userRoles,
      attr: { department: userDept },
    },
    resource: {
      kind: "document",
      id: documentId,
      attr: {
        department: docDept,
        status: docStatus,
      },
    },
    actions: ["edit"],
  });

  return decision.isAllowed("edit");
}

Decision Matrix#

The following table summarizes the key differences across all four languages. Use it as a starting point; your own requirements drive the final choice.

CriterionCedarRegoOpenFGA DSLCerbos YAML/CEL
ParadigmDeclarative policyDatalog-inspiredRelationship modelingDeclarative YAML + CEL
Learning CurveMedium (new syntax, small surface)High (unification, implicit OR across rules)Medium (the hard part is modeling)Low (YAML + single CEL expressions)
ExpressivenessABAC-focusedGeneral-purposeReBAC-focusedABAC-focused
Mixed ABAC + ReBACEntity hierarchy (in); app sends parent entities per requestGraph rules written by hand over dataCEL conditions on tuples (SpiceDB: schema + caveats)No relationship graph
Formal VerificationYesNoNoNo
Deny OverridesBuilt-in (forbid)ManualLimited (but not operator)Built-in (EFFECT_DENY)
Managed ServiceAWS Verified PermissionsSunset*Auth0 FGACerbos Hub
Open SourceCedar SDKOPA (CNCF)OpenFGACerbos PDP
PerformanceFastest (Cedar paper benchmark)Slowest for authMiddleFast
Best ForABAC + formal guaranteesInfrastructure + app policyReBAC at scaleFast adoption, app ABAC
IDE SupportVS CodeVS Code + IntelliJVS Code + IntelliJVS Code
Testing FrameworkSDK-basedBuilt-in (Rego tests)CLI assertionsYAML test files
Ecosystem BreadthAWS servicesBroadest (K8s, Terraform)Zanzibar ecosystemApplication authorization

*Styra DAS (the managed OPA option) is transitioning to community-maintained open source.

Decision Flowchart#

Relationships
(ReBAC)

Attributes
(ABAC)

Both / Mixed

Infrastructure
policy too

Yes

No

Comfortable

Prefers dedicated
language

Relationships, with
conditions on edges

Attributes, with a
shallow hierarchy

Choosing a
Policy Language

Primary authorization
model?

OpenFGA DSL
or SpiceDB Schema

Need formal
verification?

Which side
dominates?

Rego (OPA)

Cedar

Team familiarity
with YAML?

Cerbos
YAML/CEL

OpenFGA conditions
or SpiceDB caveats

For a mixed model, start from the side that dominates. When relationships dominate, keep the graph in OpenFGA or SpiceDB and attach the attribute checks to its edges. OpenFGA conditions and SpiceDB caveats are both CEL expressions, evaluated with context the caller passes at check time or stored on the tuple. When attributes dominate and the hierarchy is shallow (groups, folders, tenants), Cedar’s entity hierarchy and the in operator cover the relationship part. The cost is on the application side: Cedar does not store the graph, so every request must include the parent entities the policies need. Rego and Cerbos do not appear on this branch. Cerbos has no relationship graph, and in Rego the graph lives in hand-written rules over data.

Common Pitfalls#

Choosing Based on Benchmarks Alone#

Cedar’s performance numbers are compelling, but performance is rarely the deciding factor for policy language selection. If your authorization model is relationship-based, Cedar’s speed advantage is irrelevant because Cedar does not natively support relationship graph traversal. Choose the language that matches your authorization model first, then optimize for performance.

Underestimating Language Lock-In#

Switching policy languages means rewriting every policy, retraining every developer, and rebuilding every integration test. The effort is closer to changing your database query language than to swapping a framework. Invest time in evaluating the language before committing to it.

Ignoring the Ecosystem#

A policy language does not exist in isolation. Consider the SDK quality for your language stack, the community activity, the documentation maturity, and the long-term governance model. Rego’s broad ecosystem (Kubernetes, Terraform, Envoy) makes it valuable even if another language has better syntax for your specific use case.

Skipping Policy Testing#

Every major policy language supports testing. Cedar has SDK-based testing, Rego has a built-in test framework, OpenFGA has assertions, and Cerbos has YAML test suites. Untested authorization policies are a security liability. Treat policy testing with the same rigor as application code testing. A test also needs fixed inputs: a policy that reads the wall clock or calls http.send passes or fails depending on when and where the suite runs, so pass the time and any external data in as input.

Conclusion#

Each policy language reflects a different philosophy about authorization:

  • Cedar prioritizes safety and analyzability. If you need first-party property-style analysis over policies (Cedar Analyzer), it is the strongest fit among these four languages.
  • Rego prioritizes generality. If you need a single language for infrastructure policy, Kubernetes admission control, and application authorization, Rego’s breadth is unmatched.
  • OpenFGA DSL prioritizes relationship modeling. If your authorization is fundamentally about “who has what relationship to what,” OpenFGA’s type system maps directly to your domain.
  • Cerbos YAML/CEL prioritizes accessibility. If you want the fastest path from “we need externalized authorization” to “we have policies in production,” Cerbos minimizes the learning curve.

Define your authorization requirements before comparing syntax: which models you need (RBAC, ABAC, ReBAC), which guarantees matter (formal verification, deny overrides), and which ecosystem you operate in (AWS, Kubernetes, multi-cloud). The two defaults hold until one of those constraints outranks them: an existing OPA footprint moves the answer to Rego, and a team with no budget for a new language moves it to Cerbos.

For a broader view of platform selection and architecture patterns, see the main post in this series.

References#

External Authorization Systems

Part 4 of 4

A comprehensive guide to external authorization platforms for distributed systems. Covers platform selection, policy language comparison, cloud-native authorization with AWS, and relationship-based access control with SpiceDB and Auth0 FGA.

Related posts