Repository navigation
fix(realtime): re-authorize console tails on project transfer and re-authentication - #14989
Conversation
…authentication
A console tail keeps the project's read roles from the moment it started
and was only revalidated against the viewer's roles. Transferring a
project emitted no realtime event and changed only the project's roles, so
tails held by the previous team kept streaming. Authenticating in-band as
another user rebuilt the subscriptions but left the tails untouched.
The transfer now publishes `projects.{projectId}.update.team`, which the
realtime worker handles as a permissions change: every tail of the project
is checked against its current read roles, and the roles it keeps are
replaced so later revalidation uses them. In-band authentication
revalidates the connection's tails against the new user's roles.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. 🟡 2 medium 💬 Inline comments (1)
📍 Findings outside the diff (1) — 🟡 1 medium — defects on lines GitHub can't attach comments to🟡 Medium — Team deletion never revokes project tails · Realtime.php:936 · // src/Appwrite/Messaging/Adapter/Realtime.php
936 $permissionsChanged = $parts[2] === 'create';Tail revocation on permission change is keyed to The PR wires a revocation path for realtime tail streams: Team/Update.php emits a projects.[projectId].update.team event after an ownership transfer, the realtime worker maps it to EventTailRegistry::reauthorizeProject() with the project's fresh read roles, and the Authentication handler revalidates a connection's tails on re-authentication.
Reviewed commit: 310d9aa |
🟢 Tier S · Ready to merge
Project transfers now emit a realtime permissions-change event that refreshes project-tail authorization. In-band authentication also revalidates existing tails against the newly authenticated user's roles, with registry and websocket coverage for both flows.
📂 Walkthrough · 7
Reviewed |
There was a problem hiding this comment.
Adds realtime tail re-authorization: on project team transfer the realtime worker revokes or refreshes connected clients console.tail subscriptions via a new EventTailRegistry, with unit and e2e test coverage.
Key findings
- 🟡 Publish tail reauthorization before sub-resource propagation — Update.php:110
- 🟡 Team deletion never revokes project tails — Realtime.php:936
Security rulesNo new WARNING or ERROR findings from security rules. 6 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)
|
The event that re-authorizes a project's tails was published after the installation, repository and VCS comment permissions were rewritten. If that propagation failed, the project already belonged to the new team but the previous team's tails were never re-authorized. Publish it as soon as the project document and its cache are updated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@hansi-codes review |
What does this PR do?
A console tail (
console.tail.<projectId>) keeps the project's read roles from the moment it was subscribed. Until now it was revalidated only against the viewer's roles, and only when a permissions-changed event about that viewer arrived. That left two gaps:PATCH /v1/projects/:projectId/teamemitted no realtime event and changed only the project's roles, so tails held by members of the previous team kept streaming.This PR:
projects.{projectId}.update.team.Realtime::fromPayloadmarks it as a permissions change.EventTailRegistry::reauthorizeProject(). It checks every tail of the project against the project's current read roles and the connection's roles, drops the tails that no longer qualify, and stores the new read roles on the ones that remain so later revalidation uses them.Test Plan
Unit tests in
EventTailRegistryTest:testReauthorizeProjectDropsTailsOfViewersWhoCanNoLongerReadIttestReauthorizeProjectKeepsTheNewRolesForRevalidationBoth pass.
E2E tests in
RealtimeConsoleTailTest:testTailEndsWhenProjectIsTransferredtestTailEndsWhenConnectionAuthenticatesAsAnotherUserThese rely on CI. The local Docker stack was unavailable, so neither the passing run nor the run with the source change reverted (to show they fail without the fix) could be done locally.
Lint: Pint, PHPStan and the Rector dry run pass on the changed files.
Related PRs and Issues
addOrganizationMemberhelper inRealtimeConsoleTailTest. Whichever PR merges second needs to update the call intestTailEndsWhenProjectIsTransferred.Realtime/Message/Handlers/Authentication.php, on nearby but separate lines.🤖 Generated with Claude Code