Currently, for services that return challenges which include context about the tenant that can service a failed service request, such as authorization_url
,
Azure.Identity does not utilize this information to request a new token with the correct tenantId.
This is a proposal to enhance Azure.Identity to make it possible for service clients to interpret challenges to request tokens for the correct tenant Id, where possible.
The value of implementing this feature is:
- The ability to authenticate to Key Vaults across multiple tenants is a feature that has been requested by some customers. This would enable that scenario.
- Address the common issues encountered by our customers when using VSCode and Vs credentials with an MSA account signed in, or with multiple credentials signed in
To implement the capability to handle challenges that provide tenant Id hints, the following issues need to be addressed.
- The
TokenCredential
abstraction needs the required tenant Id context - Services that include the tenant Id hint context in their challenge response do not parse the tenantId
- Decisions need to be made about how the challenge context would be used for credentials that specify a TenantId in their options or as a required property at construction time
A TenantId property could be added to the TokenRequestContext
class.
Services that support tenantID challenges will implement a BearerTokenChallengeAuthenticationPolicy that understands how to parse the tenant Id from the challenge header.
This should be discussed as a feature crew. Some initial thoughts:
- For credentials that specify a tenantId at construction time or in options, an additional property could be added to its credential options to indicate if tenantId hints should be honored or ignored
Rough estimate for this work is ~5 days per language.