-
Notifications
You must be signed in to change notification settings - Fork 249
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d210a07
Initial plan
Copilot c0f4b9f
Fix tenant propagation in OidcIdpSignedAssertionProvider credential F…
Copilot 7402b04
Address code review feedback: improve URI handling and validate token…
Copilot 249b67c
Add unit tests for ExtractTenantFromTokenEndpointIfSameInstance metho…
Copilot 6574e5a
Merge branch 'master' into copilot/fix-tenant-propagation-issue
jmprieur ac7e841
Fix warnings in owin test apps
jmprieur 60cd6fd
Merge branch 'master' into copilot/fix-tenant-propagation-issue
jmprieur c69733f
Add E2E test for tenant override with common/organizations authority
Copilot e8ad57b
Simplify the Autonomous agent tests
jmprieur 7d94f31
Update tests/E2E Tests/AgentApplications/AutonomousAgentTests.cs
jmprieur a6d15c5
Inproving the autonomous test with tenant override
jmprieur 5c9fd28
Merge
jmprieur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
1 change: 1 addition & 0 deletions
1
src/Microsoft.Identity.Web.OidcFIC/PublicAPI/net10.0/InternalAPI.Unshipped.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| #nullable enable | ||
| static Microsoft.Identity.Web.OidcFic.OidcIdpSignedAssertionProvider.ExtractTenantFromTokenEndpointIfSameInstance(string? tokenEndpoint, string? configuredInstance) -> string? |
1 change: 1 addition & 0 deletions
1
src/Microsoft.Identity.Web.OidcFIC/PublicAPI/net462/InternalAPI.Unshipped.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| #nullable enable | ||
| static Microsoft.Identity.Web.OidcFic.OidcIdpSignedAssertionProvider.ExtractTenantFromTokenEndpointIfSameInstance(string? tokenEndpoint, string? configuredInstance) -> string? |
1 change: 1 addition & 0 deletions
1
src/Microsoft.Identity.Web.OidcFIC/PublicAPI/net472/InternalAPI.Unshipped.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| #nullable enable | ||
| static Microsoft.Identity.Web.OidcFic.OidcIdpSignedAssertionProvider.ExtractTenantFromTokenEndpointIfSameInstance(string? tokenEndpoint, string? configuredInstance) -> string? |
1 change: 1 addition & 0 deletions
1
src/Microsoft.Identity.Web.OidcFIC/PublicAPI/net8.0/InternalAPI.Unshipped.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| #nullable enable | ||
| static Microsoft.Identity.Web.OidcFic.OidcIdpSignedAssertionProvider.ExtractTenantFromTokenEndpointIfSameInstance(string? tokenEndpoint, string? configuredInstance) -> string? |
1 change: 1 addition & 0 deletions
1
src/Microsoft.Identity.Web.OidcFIC/PublicAPI/net9.0/InternalAPI.Unshipped.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| #nullable enable | ||
| static Microsoft.Identity.Web.OidcFic.OidcIdpSignedAssertionProvider.ExtractTenantFromTokenEndpointIfSameInstance(string? tokenEndpoint, string? configuredInstance) -> string? |
1 change: 1 addition & 0 deletions
1
src/Microsoft.Identity.Web.OidcFIC/PublicAPI/netstandard2.0/InternalAPI.Unshipped.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| #nullable enable | ||
| static Microsoft.Identity.Web.OidcFic.OidcIdpSignedAssertionProvider.ExtractTenantFromTokenEndpointIfSameInstance(string? tokenEndpoint, string? configuredInstance) -> string? |
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
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
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
116 changes: 116 additions & 0 deletions
116
tests/Microsoft.Identity.Web.Test/OidcIdpSignedAssertionProviderTests.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using Microsoft.Identity.Web.OidcFic; | ||
| using Xunit; | ||
|
|
||
| namespace Microsoft.Identity.Web.Test | ||
| { | ||
| public class OidcIdpSignedAssertionProviderTests | ||
| { | ||
| [Theory] | ||
| [InlineData("https://login.microsoftonline.com/my-tenant-id/oauth2/v2.0/token", "https://login.microsoftonline.com/", "my-tenant-id")] | ||
| [InlineData("https://login.microsoftonline.com/contoso.onmicrosoft.com/oauth2/v2.0/token", "https://login.microsoftonline.com", "contoso.onmicrosoft.com")] | ||
| [InlineData("https://login.microsoftonline.com/12345678-1234-1234-1234-123456789abc/oauth2/v2.0/token", "https://login.microsoftonline.com/", "12345678-1234-1234-1234-123456789abc")] | ||
| public void ExtractTenantFromTokenEndpointIfSameInstance_SameInstance_ReturnsTenant( | ||
| string tokenEndpoint, | ||
| string configuredInstance, | ||
| string expectedTenant) | ||
| { | ||
| // Act | ||
| var result = OidcIdpSignedAssertionProvider.ExtractTenantFromTokenEndpointIfSameInstance( | ||
| tokenEndpoint, | ||
| configuredInstance); | ||
|
|
||
| // Assert | ||
| Assert.Equal(expectedTenant, result); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData("https://login.microsoftonline.us/my-tenant-id/oauth2/v2.0/token", "https://login.microsoftonline.com/", null)] | ||
| [InlineData("https://login.microsoftonline.com/my-tenant-id/oauth2/v2.0/token", "https://login.microsoftonline.us/", null)] | ||
| [InlineData("https://login.chinacloudapi.cn/my-tenant-id/oauth2/v2.0/token", "https://login.microsoftonline.com/", null)] | ||
| public void ExtractTenantFromTokenEndpointIfSameInstance_DifferentInstance_ReturnsNull( | ||
| string tokenEndpoint, | ||
| string configuredInstance, | ||
| string? expectedResult) | ||
| { | ||
| // Act | ||
| var result = OidcIdpSignedAssertionProvider.ExtractTenantFromTokenEndpointIfSameInstance( | ||
| tokenEndpoint, | ||
| configuredInstance); | ||
|
|
||
| // Assert | ||
| Assert.Equal(expectedResult, result); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(null, "https://login.microsoftonline.com/")] | ||
| [InlineData("", "https://login.microsoftonline.com/")] | ||
| [InlineData("https://login.microsoftonline.com/tenant/oauth2/v2.0/token", null)] | ||
| [InlineData("https://login.microsoftonline.com/tenant/oauth2/v2.0/token", "")] | ||
| [InlineData(null, null)] | ||
| [InlineData("", "")] | ||
| public void ExtractTenantFromTokenEndpointIfSameInstance_NullOrEmptyInputs_ReturnsNull( | ||
| string? tokenEndpoint, | ||
| string? configuredInstance) | ||
| { | ||
| // Act | ||
| var result = OidcIdpSignedAssertionProvider.ExtractTenantFromTokenEndpointIfSameInstance( | ||
| tokenEndpoint, | ||
| configuredInstance); | ||
|
|
||
| // Assert | ||
| Assert.Null(result); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData("not-a-valid-uri", "https://login.microsoftonline.com/")] | ||
| [InlineData("https://login.microsoftonline.com/tenant/oauth2/v2.0/token", "not-a-valid-uri")] | ||
| public void ExtractTenantFromTokenEndpointIfSameInstance_InvalidUri_ReturnsNull( | ||
| string tokenEndpoint, | ||
| string configuredInstance) | ||
| { | ||
| // Act | ||
| var result = OidcIdpSignedAssertionProvider.ExtractTenantFromTokenEndpointIfSameInstance( | ||
| tokenEndpoint, | ||
| configuredInstance); | ||
|
|
||
| // Assert | ||
| Assert.Null(result); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData("https://login.microsoftonline.com/oauth2/v2.0/token", "https://login.microsoftonline.com/")] | ||
| [InlineData("https://login.microsoftonline.com/", "https://login.microsoftonline.com/")] | ||
| public void ExtractTenantFromTokenEndpointIfSameInstance_NoTenantInPath_ReturnsNull( | ||
| string tokenEndpoint, | ||
| string configuredInstance) | ||
| { | ||
| // Act | ||
| var result = OidcIdpSignedAssertionProvider.ExtractTenantFromTokenEndpointIfSameInstance( | ||
| tokenEndpoint, | ||
| configuredInstance); | ||
|
|
||
| // Assert | ||
| Assert.Null(result); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ExtractTenantFromTokenEndpointIfSameInstance_ValidatesOAuth2Pattern() | ||
| { | ||
| // Arrange | ||
| // This endpoint has a tenant but no oauth2 segment - should return null | ||
| var tokenEndpoint = "https://login.microsoftonline.com/my-tenant/some-other-path"; | ||
| var configuredInstance = "https://login.microsoftonline.com/"; | ||
|
|
||
| // Act | ||
| var result = OidcIdpSignedAssertionProvider.ExtractTenantFromTokenEndpointIfSameInstance( | ||
| tokenEndpoint, | ||
| configuredInstance); | ||
|
|
||
| // Assert | ||
| Assert.Null(result); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.