Prototype room-scoped Mindmap OAuth with PKCE - #594
Draft
nhyiramante1 wants to merge 4 commits into
Draft
Conversation
Review follow-ups on #594: - Key the room selection to the OAuth authorization state, not just the browser session, and consume it when the code is exchanged. Concurrent authorization tabs can no longer overwrite each other's room. - Verify token.room_id matches the launched room before loading it. - Scrub OAuth callback parameters synchronously, including failure paths. - Require wtk_ or compact-JWT shape for stored access tokens. - Show the verified registered client name and redirect origin on the room and consent screens instead of a hardcoded "Mindmap". - Replace the room picker with confirmation of the request-bound room, so the authorized room is always the launched one. - Split erasure: activity withdrawal preserves active rooms, account deletion removes them. eraseAccountData spreads loggedDataOperations() so it stays a structural superset, and the historical warning explaining why is restored. - Make room launching explicit via launchKind rather than assuming every first-party tool needs a room. Adds a Better Auth integration test covering signed-query state propagation, tampering, expiry, and missing-client rejection. That pins the oauth_query middleware coupling the new endpoints depend on: the body parameter looks unused but is what triggers signature verification. Backend 121 tests pass locally. Authored by Codex; reviewed and committed from Claude Code. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
What
This is a working vertical-slice proof of concept for replacing Mindmap's
launcher grant with a durable room plus Better Auth's OAuth Provider
Authorization Code/PKCE flow.
@better-auth/oauth-provider1.6.22 and the Better Auth JWT plugin.table.
postLogin+consentReferenceIdhooks so the chosen roomfollows consent, authorization code, and access token.
openai:chat/doc:readscopes and asigned
room_idclaim.binding at the protected resource.
non-secret room hint.
PKCE verifier, exchange the code, and load the authorized room.
/api/handoffflow in place for comparison and other tools.The detailed mental model and sequence are in
docs/oauth-rooms-pkce-poc.md.Security shape
PKCE protects the authorization code because the verifier is generated and
retained by Mindmap; it is never passed by the launcher. The room id is an
identifier, not a credential. The backend makes the room selection authoritative
and refuses a valid token against a different room.
This does not claim that browser JavaScript can identify itself
cryptographically, nor that PKCE makes a stolen bearer access token unusable.
Origin checks can remain defense-in-depth for the old flow but are not treated as
client authentication here.
Relationship to #579 and #593
wt_api; Mindmap uses itsdeploy-time backend URL, addressing the attacker-selected proxy concern on Include backend API URL in tool launches #579
for this path.
VITE_BACKEND_URL; its skippedwt_apismoke should become an OAuthlaunch/config smoke after integration.
main(ea6138d6) in a separateclean worktree. It does not include or disturb the dirty/ahead local Mindmap
worktrees.
Deliberate PoC limits
rooms, live sync, or update endpoint yet.
provisioning. Production should pre-provision the known Mindmap client (or
tightly constrain registration) and disable open registration.
Google interactive Playwright run is still needed in a configured deployment.
Validation
authorize request redirects to the configured login page with provider-signed
state
Total: 701 tests passed.