Repository navigation
fix(#455): revoke the relayed fork session on account disable (fork half) - #49
Merged
Merged
Conversation
The fork half of docmost#455 (ADR 0023): the service-bridge surface + collab seam the platform calls to revoke a disabled identity's already-issued fork credential, and the notifications-socket liveness gate — so a disabled identity cannot keep reading/writing wiki content through the fork. - service-bridge: session:revoke / session:restore scopes + POST /api/service/session/{revoke,restore}. deactivateShadowUser sets deactivatedAt + revokes user_sessions in one tx (idempotent; deactivatedAt only, never deletedAt; reuses UserRepo/UserSessionRepo, never native deactivateUser whose "already deactivated" throw breaks retry). revoke returns the resolved fork userId so the platform can also disconnect collab. reactivateShadowUser clears deactivatedAt on re-enable. - collab: node-local CollaborationGateway.forceDisconnectUser(userId) + POST /api/collab/force-disconnect-user (ESM-isolated CollabDisconnectModule). Complete at desired_count=1; an all-nodes RedisSync broadcast is a follow-up. - ws.gateway: re-check isUserDisabled + the session row at connect (policy in authz/ws-connection/), closing the 30-90d notifications-socket residual. - OpenAPI contract + scope-coverage/contract specs updated; unit + real-PG specs (deactivate -> mintSession refused round-trip) added. Upstream seams documented in the super-repo UPSTREAM_MODIFICATIONS.md (collaboration.gateway #3f, ws.gateway #161b). Co-Authored-By: Claude Opus 4.8 <[email protected]>
…on-revoke-on-disable # Conflicts: # apps/server/src/service-bridge/service-bridge.pg.spec.ts # apps/server/src/service-bridge/service-bridge.service.spec.ts # apps/server/src/service-bridge/service-bridge.service.ts
…e review gaps Review round 1 (wiki-v2 docmost#477 / docmost #49): - Security+Correctness (L3): force-close the already-open notifications socket.io connection on account disable. The connect-time isWsConnectionLive gate only refused NEW sockets, so a disabled user's already-open, ping-kept-alive feed kept streaming metadata (titles, tree moves/renames, comments) until it happened to reconnect. Add WsGateway.forceDisconnectUser (server.in(userRoom).disconnectSockets) and fan the /api/collab/force-disconnect-user seam out to BOTH the collab (Hocuspocus) and notifications (socket.io) planes. - Architecture (L3): add a two-way liveness-parity fitness test pinning isWsConnectionLive == jwt.strategy.validate so a fail-open divergence reds CI, not just a prose comment. - Testing (L3): extract the collab force-disconnect predicate into an importless authz/ helper (disconnectUserConnections) so the actual enforcement is unit-tested outside the lib0 ESM graph; the gateway method is now a thin delegate. Add a WsGateway.forceDisconnectUser unit test and SessionExternalIdDto charset-guard validation tests. - Architecture/Testing/Security (L2): OpenAPI revoke/restore bodies now $ref a SessionExternalIdRequest (externalId-only) instead of MintSessionRequest (which carried an extra clientIp). New authz/ import seam collaboration.gateway.ts added to the import-boundary SEAM_ALLOWLIST (#3f). Co-Authored-By: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
The fork half of wiki-v2 docmost#455 (ADR 0023): the service-bridge surface + collab seam the platform calls to revoke a disabled identity's already-issued fork credential, plus the notifications-socket liveness gate. Pairs with the super-repo PR (which wires
disable()/enable()and re-pins this gitlink); merge this first.What this does
session:revoke/session:restorescopes +POST /api/service/session/{revoke,restore}.deactivateShadowUser(externalId): setsdeactivatedAt+ revokes the shadow user'suser_sessionsin one tx (idempotent,deactivatedAtonly — neverdeletedAt), returns the resolved forkuserId.reactivateShadowUser(externalId): clearsdeactivatedAton re-enable.CollaborationGateway.forceDisconnectUser(userId)+POST /api/collab/force-disconnect-user(in the ESM-isolatedCollabDisconnectModule), to force-close a deactivated user's live editor sockets.isUserDisabled+ the session row at socket-io connect (policy inauthz/ws-connection/), so account disable / session revocation cut the notifications plane too.Why
Before this, a disabled platform identity kept a fork-native
authTokenthat honored the wiki content plane (/api/*, collab, notifications) for the fork TTL (30–90d) — the platform kill never reached the fork.isUserDisabled(deactivatedAt) is the one predicate every fork content entrypoint already checks (jwt.strategy,onAuthenticate,mintSession.disqualify); this exposes it to the platform over the sanctioned east-west bridge. Full rationale: wiki-v2 issue 455 + ADR 0023.How it works
disable()(super-repo) callssession/revoke→ deactivate + revoke sessions → returns the fork userId →force-disconnect-usercloses live collab sockets. Revokinguser_sessionsalone is insufficient (the 24h collab token carries nosessionId, so a pre-issued token opens new editors), which is whydeactivatedAtis the lever. Node-local disconnect is complete atdesired_count=1(the fork hosts Hocuspocus in-process); multi-node needs an all-nodes RedisSync broadcast (follow-up). NativedeactivateUseris deliberately not reused — its admin-context guards + "already deactivated" throw break the idempotent retry-before-enable contract.Acceptance criteria
mintSession(disqualify → isUserDisabled) and/api/*(jwt.strategy) — proven end-to-end against real Postgres.reactivateShadowUserrestores minting; deactivate/reactivate are idempotent + benign no-ops for a never-provisioned identity.UPSTREAM_MODIFICATIONS.md#3f, #161b); boundary check + import-boundary spec green.Testing
service-bridge.service.spec.ts(deactivate/reactivate orchestration),service-bridge-revoke.pg.spec.ts(real-PG: deactivate → mint refused → reactivate → mint OK, session revoke, idempotency),ws-connection-live.spec.ts,collab-disconnect.controller.spec.ts(per-user disconnect + DTO),service-scope-coverage.spec.ts+service-bridge.contract.spec.ts(new scopes/routes ↔ OpenAPI).scripts/check-upstream-boundary.sh+import-boundaryspec: green.Risk & rollback
Additive: new scopes/routes/methods; no change to existing behavior. The shared secret auto-grants the new scopes (no credential change). Rollback = revert; the platform's fork call is fail-closed, so an un-deployed fork simply makes
disable()503 (retryable) rather than silently degrade.Checklist
🤖 Generated with Claude Code