-
Notifications
You must be signed in to change notification settings - Fork 241
Fix tenant not propagated in credential FIC acquisition #3633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…IC acquisition Co-authored-by: jmprieur <[email protected]>
… endpoint pattern Co-authored-by: jmprieur <[email protected]>
jmprieur
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the e2e tests move to id4slab1 we'll add one with the common authority and forcing the tenant to be set in AcquireaTokenOptions
| /// <param name="tokenEndpoint">Token endpoint URL in the format https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token</param> | ||
| /// <param name="configuredInstance">The configured instance URL (e.g., https://login.microsoftonline.com/)</param> | ||
| /// <returns>The tenant ID if the endpoint is from the same instance, otherwise null.</returns> | ||
| private static string? ExtractTenantFromTokenEndpointIfSameInstance(string? tokenEndpoint, string? configuredInstance) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot please create a unit test for this new method (and have it internal so that the unit test can call it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the method internal and added comprehensive unit tests covering:
- Same instance scenarios returning the correct tenant
- Different instance (cross-cloud) scenarios returning null
- Null/empty input handling
- Invalid URI handling
- Missing tenant in path scenarios
- OAuth2 pattern validation
Commit: 249b67c
…d and make it internal Co-authored-by: jmprieur <[email protected]>
bgavrilMS
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok as a temporary fix, but waiting for MSAL is probably better.
|
I agree. When can we have it in msal, @bgavrilMS ?. (It's blocking a partner) |
jmprieur
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot in
| configuration["AzureAd:ClientId"] = "d05619c9-dbf2-4e60-95fd-cc75dd0db451"; // Agent application. |
options.AcquireTokenOptions.Tenant = "31a58c3b-ae9c-4448-9e8f-e9e143e800df")
Ideally a Theory with Inlines?
Co-authored-by: jmprieur <[email protected]>
Added a Theory test
Commit: c69733f |
Fixes the issue where tenant override is not propagated to the credential FIC token acquisition in
OidcIdpSignedAssertionProvider.GetClientAssertionAsync.Description
This PR implements a temporary workaround to extract tenant information from
AssertionRequestOptions.TokenEndpointuntil MSAL adds native support forTenantIdproperty inAssertionRequestOptions(tracked in MSAL PR #5573).Changes Made
AssertionRequestOptions.TokenEndpointwhen it matches the configured cloud instanceAcquireTokenOptions.Tenant, it flows through to theTokenEndpoint, and this fix propagates it to the credential FIC acquisitionExtractTenantFromTokenEndpointIfSameInstancemethod internal for testabilityExtractTenantFromTokenEndpointIfSameInstancemethod covering same instance, cross-cloud, null/empty inputs, invalid URIs, and OAuth2 pattern validation scenariosAutonomousAgentWithTenantOverride_GetsAppTokenForAgentIdentityAsyncas a Theory with InlineData for "common" and "organizations" scenarios to validate tenant override functionalityTechnical Details
TokenEndpointinAssertionRequestOptionscontains the tenant for the current request (e.g.,https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token)TokenEndpointAcquireTokenOptions.Tenantfor the credential FIC acquisitionTokenEndpointhost matches the configured instance hostTesting
tidclaim in issued tokensOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.