---
title: "Discussion on \"Writing Agent Authorization as Code with Cedar\" | Hashnode"
description: "Discussion on \"Writing Agent Authorization as Code with Cedar\". Agent authorization as Cedar policy: a schema, grants as data, three rules, and tests that assert why a call was denied."
url: "https://hashnode.com/posts/agent-authorization-policy-as-code/6ae167e8986e1037a6b00499"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Writing Agent Authorization as Code with Cedar](https://dvaddi.hashnode.dev/agent-authorization-policy-as-code?utm_source=hashnode&utm_medium=feed)

Agent authorization as Cedar policy: a schema, grants as data, three rules, and tests that assert why a call was denied.

Oct 28 · 20 min read · dvaddi.hashnode.dev  
Updated Nov 5  
Read the article

-   [#ai-agents](https://hashnode.com/tag/ai-agents)
-   [#authorization](https://hashnode.com/tag/authorization)
-   [#mcp](https://hashnode.com/tag/mcp)
-   [#security](https://hashnode.com/tag/security)
-   [#cedar](https://hashnode.com/tag/cedar)

## Written by

[dvaddi](https://hashnode.com/@dvaddi)

@dvaddi

  
[View profile](https://hashnode.com/@dvaddi)

## Responses 6

Markdown supported · ⌘↵ to post

[Mike Dabydeen](https://hashnode.com/@firelinks)

[Oct 28](https://hashnode.com/posts/agent-authorization-policy-as-code/6ae167e8986e1037a6b00499/comment/6ae1db5f02d94ec9076bc2ba)

The 28 tests prove the policies against the entities in tests.json, but production decisions run against the real grant store, and the suite never sees it. If someone adds billing to the support-assistant agent's write\_groups, every test still passes. Since the Agent entity isn't per tenant, that one change reaches every tenant whose users and tenant already hold billing.

Because grants are data, I'd give the data its own check. On each change to the entity store, run cedar authorize for every agent, tool and action in each tenant, keep the set of ALLOWs, and diff it against the last run. Any new ALLOW on write or destroy goes to a reviewer before the change takes effect. That gives grant changes the same scrutiny your policy files already get.

[dvaddi](https://hashnode.com/@dvaddi)

[Nov 1](https://hashnode.com/posts/agent-authorization-policy-as-code/6ae167e8986e1037a6b00499/comment/6ae1db5f02d94ec9076bc2ba#reply-6ae78d996498e0a9ae73fcff)

You’re right, and it’s a gap in my refinement, not just the post. The destroy forbid needs a different user, same tenant, holding the same write grant, so destroy reachability is a property of the user table, not of agent ∩ tenant. A synthetic approval assumes that second user exists; for a one-holder tenant that’s wrong, and the day an admin adds a second holder, destroy opens with no agent or tenant edit.

Taking your count. Per tenant and write group: the number of users who hold it. One to two is flagged like a new ALLOW on destroy; two to one is logged, since it quietly breaks destroy for that tenant. The ceiling run then drops destroy altogether — it reports write, and the holder count decides destroy. Two checks that compose, instead of one pretending to cover both.

The approver being a User entity with a signed, nonce-burned approval already rules out an agent standing in as the second person, so the count is of people, which is what the rule means. Will update the section notes.

[dvaddi](https://hashnode.com/@dvaddi)

[Nov 5](https://hashnode.com/posts/agent-authorization-policy-as-code/6ae167e8986e1037a6b00499/comment/6ae1db5f02d94ec9076bc2ba#reply-6aebee15508c706ce4245a31)

You were right, and the check changed: the ceiling reports write only, and the same snapshot carries a per-tenant count of User entities holding each write group (an agent never counts, approved\_by is typed User). A move from fewer than two holders to two or more fails the build like a new write allow, the other way is logged, and Part 3 now says plainly that two holders is the ceiling for destroy, not a permit. It’s in Part 3, “Grants are data, and data needs its own check”.

[dvaddi](https://hashnode.com/@dvaddi)

[Nov 5](https://hashnode.com/posts/agent-authorization-policy-as-code/6ae167e8986e1037a6b00499/comment/6ae1db5f02d94ec9076bc2ba#reply-6aebee77f1f626b8759f9add)

Done in Part 3: the build now runs a ceiling pass over the grant data, read and write for every agent and tool per tenant with a user who holds exactly the tenant’s grants, and keeps the ALLOW set as a committed snapshot; any difference fails the build and a new write allow lands under a REVIEW header. Your billing edit is the fixture: all 28 cases still pass and the gate rejects it in both tenants. Part 3, “Grants are data, and data needs its own check”.
