Repository navigation
auth: Add BearerChallengePolicy for MFA step-up challenges during subscription listing - #2231
Merged
Alex Weininger (alexweininger) merged 2 commits intoMar 20, 2026
Merged
Conversation
The auth package creates SubscriptionClient instances to list tenants and subscriptions, but these clients had no challenge policy on their HTTP pipeline. When users hit an MFA step-up challenge (401 with WWW-Authenticate header) during tenant/subscription listing, the request simply fails. Changes: - Create BearerChallengePolicy in auth/src/utils/BearerChallengePolicy.ts - Wire into SubscriptionClient pipeline in AzureSubscriptionProviderBase - Export BearerChallengePolicy and getDefaultScopeFromEndpoint - Add @azure/core-rest-pipeline as devDependency - Bump version to 6.0.0-alpha.6 Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an authentication pipeline policy to handle MFA “step-up” (401 + WWW-Authenticate) challenges during tenant/subscription listing, so SubscriptionClient requests can transparently retry with a stepped-up token instead of failing.
Changes:
- Introduces
BearerChallengePolicy+getDefaultScopeFromEndpointutility exported fromauth - Wires the policy into
AzureSubscriptionProviderBase.getSubscriptionClient()after bearer token signing - Bumps
@microsoft/vscode-azext-azureauthto6.0.0-alpha.6and adds an Azure pipeline dependency
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| auth/src/utils/BearerChallengePolicy.ts | New pipeline policy to handle 401 challenges by acquiring a stepped-up token and retrying once |
| auth/src/providers/AzureSubscriptionProviderBase.ts | Adds the new policy to the SubscriptionClient pipeline for subscription listing |
| auth/src/index.ts | Exports the new policy and helper function from the package |
| auth/package.json | Version bump and adds @azure/core-rest-pipeline dependency (currently as devDependency) |
Files not reviewed (1)
- auth/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- Move @azure/core-rest-pipeline back to regular dependencies since BearerChallengePolicy is exported and its .d.ts references pipeline types - Replace HTTP header-based retry marker (x-azext-challenge-retry) with a WeakSet to track retried requests out-of-band, avoiding sending the marker over the wire Co-authored-by: Copilot <[email protected]>
Brandon Waterloo (bwateratmsft)
approved these changes
Mar 20, 2026
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.
Problem
The auth package creates
SubscriptionClientinstances to list tenants and subscriptions, but these clients had no challenge policy on their HTTP pipeline. When users hit an MFA step-up challenge (401 withWWW-Authenticateheader) during tenant/subscription listing, the request simply fails.The challenge policy previously only existed in the
azurepackage (AzExtBearerChallengePolicy), applied only to clients created viacreateAzureClient().Solution
BearerChallengePolicyinauth/src/utils/BearerChallengePolicy.ts— intercepts 401 + WWW-Authenticate, retries once with a stepped-up tokenAzureSubscriptionProviderBase.getSubscriptionClient()at theSignphase withafterPolicies: ['bearerTokenAuthenticationPolicy']BearerChallengePolicyandgetDefaultScopeFromEndpointfrom the package6.0.0-alpha.6Related
Follow-up
A separate PR will update the
azurepackage to consumeBearerChallengePolicyfrom auth instead of maintaining its own duplicate.