fix(plugins): support AAD v1 (sts.windows.net) issuer in token validation#483
Open
heyitsaamir wants to merge 2 commits into
Open
fix(plugins): support AAD v1 (sts.windows.net) issuer in token validation#483heyitsaamir wants to merge 2 commits into
heyitsaamir wants to merge 2 commits into
Conversation
…ation Tenant-based issuer validation in TeamsValidationSettings now accepts both the AAD v2 issuer (login endpoint) and the AAD v1 issuer (https://sts.windows.net/{tenantId}/), since some valid Microsoft Entra tokens are still issued with the v1 issuer format. Mirrors microsoft/teams.ts#556.
Contributor
There was a problem hiding this comment.
Pull request overview
Extends tenant-scoped issuer validation in the AspNetCore plugin so Entra token validation accepts both the cloud-specific login endpoint issuer and the AAD v1 sts.windows.net/{tenantId}/ issuer, aligning behavior with tokens that still present the v1 issuer format.
Changes:
- Updated
TeamsValidationSettings.GetValidIssuersForTenantto return both the login-endpoint issuer andhttps://sts.windows.net/{tenantId}/. - Adjusted the existing cloud-endpoint unit test to expect two issuers and added a new unit test verifying inclusion of the v1 STS issuer.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Libraries/Microsoft.Teams.Plugins/Microsoft.Teams.Plugins.AspNetCore/Extensions/TeamsValidationSettings.cs | Adds AAD v1 sts.windows.net issuer to tenant-based issuer list returned for Entra token validation. |
| Tests/Microsoft.Teams.Plugins.AspNetCore.Tests/Extensions/TeamsValidationSettingsTests.cs | Updates issuer expectations and adds coverage for v1 STS issuer inclusion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8 tasks
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.
Summary
Mirrors microsoft/teams.ts#556 for teams.net.
Extends tenant-based issuer validation in
TeamsValidationSettings.GetValidIssuersForTenantto also accept the Azure AD v1 issuer format (https://sts.windows.net/{tenantId}/) in addition to the v2 issuer ({LoginEndpoint}/{tenantId}/).Motivation
Some valid Microsoft Entra tokens are issued with the AAD v1 issuer (
sts.windows.net) instead of the v2-stylelogin.microsoftonline.com/.../v2.0issuer. Without this change, tenant-based validation rejects otherwise-valid v1 tokens.See: https://learn.microsoft.com/en-us/entra/identity-platform/access-tokens
Changes
Libraries/Microsoft.Teams.Plugins/Microsoft.Teams.Plugins.AspNetCore/Extensions/TeamsValidationSettings.cs:GetValidIssuersForTenantnow returns both the v2 (cloud-specific login endpoint) and v1 (sts.windows.net) issuers for the configured tenant.Tests/Microsoft.Teams.Plugins.AspNetCore.Tests/Extensions/TeamsValidationSettingsTests.cs: updatedGetValidIssuersForTenant_UsesCloudLoginEndpointto expect both issuers and addedGetValidIssuersForTenant_IncludesV1StsIssuer.Notes on scope
Libraries/Microsoft.Teams.Apps/doesn't contain JWT/issuer validation logic; the inbound auth pipeline lives in the AspNetCore plugin.core/already handles this —Microsoft.Teams.Core/Hosting/JwtExtensions.ValidateTeamsIssueralready accepts both v1 (sts.windows.net/{tid}/) and v2 (login.microsoftonline.com/{tid}/v2.0) issuers, so no change is needed there. See https://github.com/microsoft/teams.net/blob/main/core/src/Microsoft.Teams.Core/Hosting/JwtExtensions.cs#L159-L162.Test plan
dotnet test Tests/Microsoft.Teams.Plugins.AspNetCore.Tests --filter "FullyQualifiedName~TeamsValidationSettings"— all 10 tests pass on net8.0 and net10.0.dotnet build Libraries/Microsoft.Teams.Plugins/Microsoft.Teams.Plugins.AspNetCore— succeeds with 0 warnings / 0 errors.