Repository navigation
fix(presences): keep the owner's update and delete when a client sets permissions - #14396
Conversation
… permissions A client that upserted its presence with only read roles, as the docs show, could no longer heartbeat, update or delete it: the given permissions replaced the owner's. Client-set permissions now always keep update and delete for the user who wrote them.
|
Review complete. No blocking issues — approved ✅; 1 nitpick below. 🧹 Nitpicks (1) — 🟢 1 low
This PR modifies
Reviewed commit: 15106c8 |
🟢 Tier S · Ready to merge
Client-session presence permissions now retain the owner's update and delete access when custom sharing permissions are supplied, while API keys and privileged callers retain the permissions they provide. The presence e2e regression verifies that a client can heartbeat, update, and delete a presence shared with read-only permissions. Latest changes: The newest commit switches owner update/delete permission construction to the
📂 Walkthrough · 2
Merged |
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
What does this PR do?
permissions,PresenceState::setPermissions()now always addsupdate("user:<id>")anddelete("user:<id>")for that user. Before, the given permissions replaced the owner's, so a presence shared with[Permission.read(Role.users())], as the docs show, could no longer be heartbeated, updated or deleted by its own owner.testUpsertPresenceWithReadPermissionscovers the heartbeat, update and delete of a presence shared withread("users")only.Verification
A client session on a local stack upserts its presence with
permissions: ['read("users")'](REST and realtime), then:PUT /v1/presences/:idagain (heartbeat)user_unauthorizedPATCH /v1/presences/:id{status: 'away'}DELETE /v1/presences/:idupsertPresencefrom a second realtime connection of the same userThe created presence now carries
delete("user:<id>"),read("users"),update("user:<id>").testUpsertPresenceWithReadPermissionsfails on main (401 on the heartbeat). The Presences e2e suite passes against this branch, except the two maintenance-expiry tests, which need the Docker socket my test container did not have. Pint and PHPStan pass on the changed file.Fixes #14341