feat(auth): remember last workspace and skip Auth0 workspace prompt on login - #34
Merged
Merged
Conversation
…n login After a successful token exchange, persist the Auth0 organization (org_id claim, falling back to https://confidence.dev/org_login_id) next to the existing token files. Subsequent interactive logins pass it as the organization parameter to the authorize endpoint so Auth0 skips the workspace-id prompt. Signup stays org-less. The CONFIDENCE_ORGANIZATION env var overrides the remembered value, and an Auth0 error on the callback triggers one retry without the organization parameter instead of failing hard. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
filipmyllari
marked this pull request as ready for review
August 19, 2026 06:31
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
Interactive logins currently always route the user through Auth0's workspace-id prompt because the authorize URL never includes an
organizationparameter. This PR makes the CLI remember the workspace after a successful login and pass it along next time:org_idclaim, falling back tohttps://confidence.dev/org_login_id) is persisted to$TMPDIR/confidence_organization, next to the existing token files, with the same0600mode.organizationparameter in the authorize URL, so Auth0 skips the workspace prompt. Signup stays org-less — the signup client is unaffected.CONFIDENCE_ORGANIZATIONenv var overrides the remembered value (to log into a different workspace).organizationparameter — one retry instead of failing hard.scripts/clean-dev-env.sh --authnow also removes the remembered organization.Why now
This composes with the planned Auth0 "Prompt for Credentials" flip: after that flip Auth0 itself no longer prompts for a workspace id, but passing
organizationstill skips the post-login workspace picker — so remembering the last workspace keeps repeat logins one-click either way.Tests
New
__tests__/lib/auth.test.tsexercises the real PKCE flow (real callback server, MSW for the token exchange, mocked browser opener) and covers:organizationon first loginorg_idandorg_login_idfallback)CONFIDENCE_ORGANIZATIONenv overrideorganizationorganizationwhen Auth0 returns an errorpnpm qa(typecheck + lint + 114 tests) andpnpm test:e2e(36 tests) pass.🤖 Generated with Claude Code