Debugging authorization decisions :: Cerbos Authorization Management Platform // Documentation

Debugging authorization decisions

When a request returns an unexpected EFFECT_ALLOW or EFFECT_DENY, Cerbos provides several tools to help you understand why.

Using includeMeta in requests

Add "includeMeta": true to your CheckResources request to receive metadata about how Cerbos reached each decision.

Request with includeMeta

{
  "requestId": "debug-example",
  "includeMeta": true,
  "principal": {
    "id": "alice",
    "roles": ["employee"],
    "attr": {
      "department": "marketing"
    }
  },
  "resources": [
    {
      "resource": {
        "kind": "leave_request",
        "id": "xx125",
        "policyVersion": "20210210",
        "attr": {
          "owner": "alice"
        }
      },
      "actions": ["view", "approve"]
    }
  ]
}

The response includes a meta block for each resource:

Response meta block

{
  "meta": {
    "actions": {
      "view": {
        "matchedPolicy": "resource.leave_request.v20210210/acme.corp",
        "matchedScope": "acme",
        "effectiveDerivedRoles": ["owner"]
      },
      "approve": {
        "matchedPolicy": "resource.leave_request.v20210210/acme.corp"
      }
    }
  }
}

matchedPolicy

The full identifier of the policy that produced the decision.

matchedScope

The scope that was active when the decision was made (relevant when using scoped policies).

effectiveDerivedRoles

The derived roles that were activated for the principal on this resource. If a role you expected is missing, check the derived roles definition and its conditions.

Audit logging

Enable decision logging to record every authorization decision made by the Cerbos PDP. This is useful for post-hoc analysis and for correlating decisions with application behaviour.

Minimal audit configuration

audit:
  enabled: true
  decisionLogsEnabled: true
  backend: file
  file:
    path: stdout

Every API response includes a cerbosCallId field. Use this identifier to locate the corresponding entry in the audit log.

See audit configuration for the full set of options including filtering, retention, and alternative backends.

Testing CEL expressions with the REPL

The Cerbos REPL lets you evaluate CEL expressions interactively, which is useful for debugging conditions that aren’t behaving as expected.

You can load request data and test expressions against it without running a full policy evaluation cycle. See the REPL documentation for usage details.

Common causes of unexpected DENY

If a request is denied when you expect it to be allowed, check the following:

Common causes of unexpected ALLOW

Validating and inspecting policies

Use cerbos compile to validate policies and run tests before deploying them. This catches syntax errors, missing imports, and failing test cases.

See validating and testing for the full guide on policy compilation and test suites.