feat(cedar): add namespace option for namespaced Cedar policies - #2896
Conversation
Add a `namespace` config option to CedarAuthorization that prefixes
action and resource types in the authorization request (e.g.
`Agent::Action::"search"` instead of `Action::"search"`).
When namespace is set:
- Action type becomes `{namespace}::Action`
- Resource type becomes `{namespace}::McpServer` with id `default`
- Default principal type becomes `{namespace}::User`
- Schema generation preserves the namespace wrapper
When namespace is not set (default), behavior is unchanged — types
remain unnamespaced for backward compatibility.
This enables integration with policy generators like
cedar-agent-policy-builder that produce namespaced Cedar policies
following the cedar-for-agents MCP schema conventions.
|
Issue (Important): This adds a new public config option but the diff doesn't touch the user-facing docs. The Cedar Authorization page ( Also, as a new public API surface on a vended intervention, this looks like it should carry the |
|
Assessment: Request Changes The Review themes
The backward-compatibility design is solid and the inline JSDoc on the new option is clear — nicely scoped once the schema-generation path is sorted out. |
Signed-off-by: Victor Nicolet <victornl@amazon.com>
|
Re-review of Assessment: Comment (close to approval) The correctness and testing concerns from the first pass are resolved, verified locally (all 39 Cedar tests pass):
Two items from the original review are still open and not addressed by this commit: Remaining (non-blocking)
Nice, focused iteration — the implementation side looks good to me now. |
|
if you could put an api example in the pr description before/after merge that would be great. similarly, if you wanted to do follow ups for python / docs site, if not happy to do them when i'm back. |
Added a little bit more description of how it changes the API.
I'll follow up with the docs site soon, the python will probably come later since the use case isn't as pressing (we don't have a policy generator plan in Python?). |
Summary
Adds a
namespaceconfig option toCedarAuthorizationthat prefixes action and resource types in the authorization request. This will allow using Cedar's tool directly, get full schema validation support, and better integration with the proposed Cedar policy builder: cedar-policy/cedar-for-agents#137.We can do a follow up PR for Python, but afaik, there is not Python policy builder yet, so the need isn't as pressing.
Motivation
Policy generators like cedar-agent-policy-builder produce namespaced Cedar policies following the
@cedar-policy/mcp-schema-generator-wasmconventions (e.g.Agent::Action::"search"). Currently,CedarAuthorizationhardcodes unnamespaced types (Action::"search"), making it incompatible with these policies.Changes
namespace?: stringtoCedarAuthorizationConfig{ns}::Action, resource →{ns}::McpServer::"default", default principal →{ns}::User::"anonymous"Usage
Before the merge,
CedarAuthorizationgenerates a schema without a namespace:The type of the principal is
User, without namespace. Policies and entities referenceUserfor the users, andResource. This is convenient for quick writing quick policies, but doesn't work once you start integrating with other Cedar or agents tools (such as the policy generator e.g. in lizradway/cedar-for-agents#2).After the merge, you can add an optional namespace:
The type of principals is
Agent::Userand the agent is represented byAgent::Resource. You can use policies that fully validate against schemas generated by thecedar-policy-mcp-schema-generator, or use other policy generators.Testing
3 new tests added, all 39 Cedar tests pass.