feat(auth): add multi-account session management#207
Open
Mathf18 wants to merge 4 commits intomicrosoft:mainfrom
Open
feat(auth): add multi-account session management#207Mathf18 wants to merge 4 commits intomicrosoft:mainfrom
Mathf18 wants to merge 4 commits intomicrosoft:mainfrom
Conversation
- Replace deprecated datetime.utcnow() with datetime.now(timezone.utc) - Add case-insensitive username matching in session resolution - Cache MSAL app per tenant in list_accounts to avoid redundant creation - Log TypeError instead of silently swallowing in _get_matching_account - Add clarifying comments on acquire_token branching logic - Only reset MSAL app when tenant actually changes (set_tenant, _sync) - Expand docs with parameter descriptions and behavior details - Add edge case tests: env var block, case-insensitive switch, 3+ account prompt, cancelled prompt, empty list, app preservation on tenant match Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
|
@microsoft-github-policy-service agree |
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.
Closes #206
Summary
fab auth listto display all stored user sessions (active, valid, tenant, last used)fab auth switchto switch between stored sessions - direct (-u,-t) or interactive promptfab auth logoutwith per-session removal (-u,-t) and bulk clear (--all)FAB_TOKEN, etc.) is activefab auth loginso new accounts are always stored as distinct sessionsUse case
Consultants and developers working across multiple Fabric tenants (e.g. Client A production, Client B dev, internal corporate) currently need a full logout/login cycle to switch context. This PR lets them authenticate once per account and switch instantly:
Verification
uv run pytest tests/test_core/test_fab_auth.py tests/test_commands/test_auth.pyTest plan
fab auth loginwith interactive browser - stores session correctlyfab auth loginwith a second account - both sessions visible infab auth listfab auth switch -u <name>- switches directly (case-insensitive)fab auth switchwith 2 sessions - auto-togglesfab auth switchwith 3+ sessions - shows interactive promptfab auth switchwithFAB_TOKENset - returns clear errorfab auth logout -u <name>- removes only that sessionfab auth logout --all- clears everythingfab auth status- reflects the active session