Repository navigation
fix(relationships): link by the key on the written document with read permission - #1044
Conversation
… permission 8.0.1 made every nested link to an existing related document need update permission on it. Where the link is only the key on the document being written, a one-way one-to-one, a many-to-one, or a one-to-many child pointing at its parent, nothing on the related document is written, yet linking to a document the caller may only read now fails with "No permissions provided for action 'update'". 7.x linked these with read permission, so read-only lookup collections stopped accepting links after the upgrade. These links need read permission again, on create, update, and in authorizeCreate() and authorizeUpdate(). Links that write the related document or a junction row (many-to-many, two-way one-to-one, one-to-many parent, many-to-one child) still need update permission, a related document sent with attributes to change still needs update permission, and a stored document the caller cannot read is still refused.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Links by the key on the written row (many-to-one, one-way one-to-one, one-to-many child) need only read permission on the related row again, as before 8.0.1 (utopia-php/database#1044). Also takes the cache invalidation retry from 8.3.11 (utopia-php/database#1043).
What changed
Since 8.0.1 (#1002, commit 1730bb7), linking any existing related document needs update permission on it. When the link is only the key on the document being written, the related document is not written at all, so the update check is not needed. This applies to a one-way one-to-one, a many-to-one, and a one-to-many child pointing at its parent. These links need read permission again, as in 7.x. The change covers
createDocument(),updateDocument(),authorizeCreate()andauthorizeUpdate().Unchanged:
writesById()is renamedwritesRelated(), since it now also decides the document-value path. UPGRADE.md is updated to match.Tested
create/read/update("users")to one granting onlyread("users"), linked by ID as a user. It fails withNo permissions provided for action 'update'on 8.3.11 and is created on this branch, one-way and two-way. Memory adapter.tests/unit/Relationships: 2557 tests pass. InNestedLinkPermissionsTestandStagedViewAuthorizationTest, one-way one-to-one and many-to-one links by ID to a read-only document now expect success.testANestedDocumentIsJudgedAgainstTheLinksTheStagedWritesLeavenow uses a two-way one-to-one, a link that still needs update.PermissionTests::testNestedRelatedDocumentsFollowTheLinkRulenow expects many-to-one by ID without update to succeed. It was not run locally because the e2e adapters need ext-redis.Summary by CodeRabbit
Bug Fixes
Documentation