fix(server): prevent duplicate desktop clients after restart - #6305
fix(server): prevent duplicate desktop clients after restart#6305seeb1337 wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review This PR modifies authentication/session management code in You can customize Macroscope's approvability policy. Learn more. |
Summary
Root cause
The desktop bootstrap credential is intentionally reusable, but desktop and WSL bearer credentials are cached only for the lifetime of the app process. Each restart therefore exchanged the bootstrap credential again and
SessionStorepersisted another 30-day bearer session without revoking the previous one.Tests
vp test apps/server/src/auth/SessionStore.test.ts apps/server/src/auth/EnvironmentAuth.test.tsvp test apps/server/src/server.test.ts apps/server/src/persistence/RepositoryErrorCorrelation.test.tsvp checkvp run typecheckNote
Medium Risk
Touches auth session issuance and revocation persistence, including transactional revoke-and-create for matching sessions. Scoped to desktop-bootstrap exchanges and covered by concurrent replacement tests.
Overview
Stops desktop restarts from stacking duplicate authorized clients by rotating bearer sessions minted from the reusable desktop bootstrap credential.
exchangeBootstrapCredentialForAccessTokennow setsreplaceActiveForSubjectAndMethodfordesktop-bootstrapgrants.SessionStore.issueand a new transactionalAuthSessionRepository.createReplacingActiverevoke matching active subject+method sessions before inserting the new one, then emit client-removed updates. Browser and other paired sessions stay intact; only the previous desktop bearer token is invalidated.Reviewed by Cursor Bugbot for commit b0f4893. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Prevent duplicate desktop clients by revoking prior bearer sessions on reconnect
createReplacingActivetoAuthSessionRepository, which revokes matching sessions in a single transaction and returns their IDs.SessionStoreemitsclientRemovedevents for each revoked session so connected-session state stays consistent.EnvironmentAuthsetsreplaceActiveForSubjectAndMethodwhen issuing sessions from adesktop-bootstrapgrant.Macroscope summarized b0f4893.