Skip to content

fix(cedar): always use ForgeDB::Document as resource entity type#18

Merged
jonathanmagambo merged 1 commit intomainfrom
fix/cedar-resource-entity-type
Mar 12, 2026
Merged

fix(cedar): always use ForgeDB::Document as resource entity type#18
jonathanmagambo merged 1 commit intomainfrom
fix/cedar-resource-entity-type

Conversation

@jonathanmagambo
Copy link
Copy Markdown
Collaborator

Collection names like 'user' were being capitalized and used as Cedar entity types — colliding with the 'User' principal type registered in the schema. Cedar's Request::new() with strict schema validation then rejected the request outright, bubbling up as a 403 Forbidden on every read from a collection whose name matched a Cedar entity type.

Fix: hardcode ForgeDB::Document as the resource entity type for all collection and document routes. The full collection/id string goes in the entity ID anyway, so Cedar policies can still discriminate at any granularity via ForgeDB::Document::"collection/id".

Also fix the TUI editor buffer to show the inner doc object from the server's {id, doc} response wrapper instead of the wrapper itself, preventing redundant id fields from appearing on re-save.

Adds regression test: collection_named_user_resolves_as_document_not_principal_type

Collection names like 'user' were being capitalized and used as Cedar
entity types — colliding with the 'User' principal type registered in
the schema. Cedar's Request::new() with strict schema validation then
rejected the request outright, bubbling up as a 403 Forbidden on every
read from a collection whose name matched a Cedar entity type.

Fix: hardcode ForgeDB::Document as the resource entity type for all
collection and document routes. The full collection/id string goes in
the entity ID anyway, so Cedar policies can still discriminate at any
granularity via ForgeDB::Document::"collection/id".

Also fix the TUI editor buffer to show the inner doc object from the
server's {id, doc} response wrapper instead of the wrapper itself,
preventing redundant id fields from appearing on re-save.

Adds regression test: collection_named_user_resolves_as_document_not_principal_type
@jonathanmagambo jonathanmagambo merged commit 6fb0d2b into main Mar 12, 2026
1 check failed
@jonathanmagambo jonathanmagambo deleted the fix/cedar-resource-entity-type branch March 12, 2026 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant