Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,16 @@ public async Task<AcquireTokenResult> AddAccountToCacheFromAuthorizationCodeAsyn
}
}


/// <summary>
/// Allows creation of confidential client applications targeting regional and global authorities
/// when supporting managed identities.
/// </summary>
/// <param name="mergedOptions">Merged configuration options</param>
/// <returns>Concatenated string of authority, cliend id and azure region</returns>
private static string GetApplicationKey(MergedOptions mergedOptions)
{
return mergedOptions.Instance! + mergedOptions.ClientId;
return DefaultTokenAcquirerFactoryImplementation.GetKey(mergedOptions.Authority, mergedOptions.ClientId, mergedOptions.AzureRegion);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,41 @@ public async Task VerifyCorrectRedirectUriAsync(
}
}

[Fact]
public async Task VerifyDifferentRegionsDifferentApp()
{
_microsoftIdentityOptionsMonitor = new TestOptionsMonitor<MicrosoftIdentityOptions>(new MicrosoftIdentityOptions
{
Authority = TC.AuthorityCommonTenant,
ClientId = TC.ConfidentialClientId,
CallbackPath = string.Empty,
});

_applicationOptionsMonitor = new TestOptionsMonitor<ConfidentialClientApplicationOptions>(new ConfidentialClientApplicationOptions
{
Instance = TC.AadInstance,
RedirectUri = "http://localhost:1729/",
ClientSecret = TC.ClientSecret,
});

BuildTheRequiredServices();
MergedOptions mergedOptions = _provider.GetRequiredService<IMergedOptionsStore>().Get(OpenIdConnectDefaults.AuthenticationScheme);
MergedOptions.UpdateMergedOptionsFromMicrosoftIdentityOptions(_microsoftIdentityOptionsMonitor.Get(OpenIdConnectDefaults.AuthenticationScheme), mergedOptions);
MergedOptions.UpdateMergedOptionsFromConfidentialClientApplicationOptions(_applicationOptionsMonitor.Get(OpenIdConnectDefaults.AuthenticationScheme), mergedOptions);

InitializeTokenAcquisitionObjects();

mergedOptions.AzureRegion = "UKEast";

IConfidentialClientApplication appEast = await _tokenAcquisition.GetOrBuildConfidentialClientApplicationAsync(mergedOptions);

mergedOptions.AzureRegion = "UKWest";

IConfidentialClientApplication appWest = await _tokenAcquisition.GetOrBuildConfidentialClientApplicationAsync(mergedOptions);

Assert.NotSame(appEast, appWest);
}

[Theory]
[InlineData(true)]
[InlineData(false)]
Expand Down