Security improvements in Spring Cloud Azure AAD#49033
Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens default AAD JWT validation behavior in spring-cloud-azure-autoconfigure by enforcing tenant-aware issuer validation for single-tenant resource servers and enabling explicit audience validation by default in AadAuthenticationFilter.
Changes:
- Wire
AadResourceServerConfigurationissuer validation to useAadTrustedIssuerRepositoryfor single-tenant tenant IDs while preserving legacy prefix-based issuer validation forcommon/organizations/consumers. - Change
AadAuthenticationFilterdefault constructors to enable explicit audience checking by default. - Add/update tests covering the new default behaviors.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/aad/filter/AadAuthenticationFilter.java | Switch constructor defaults to enable explicit audience validation. |
| sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/aad/configuration/AadResourceServerConfiguration.java | Use trusted-issuer exact matching for single-tenant issuer validation; keep multi-tenant legacy behavior. |
| sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/implementation/aad/filter/AadAuthenticationFilterTests.java | Add tests validating constructor defaults for explicit audience checking. |
| sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/implementation/aad/configuration/AadResourceServerConfigurationTests.java | Add tests validating single-tenant vs multi-tenant issuer validator wiring. |
| sdk/spring/CHANGELOG.md | Document the hardened defaults in changelog. |
|
@copilot apply changes based on the comments in this thread |
…pplication, fix changelog link Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-java/sessions/ac6fd8b6-366e-4630-bcaf-fee4ad6e62c3 Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Applied all three changes from the review thread in commit
|
|
Ignore the test failure about java - spring - ci (Build Test ubuntu2404_121_NotFromSource_TestsOnly), it's a know issue: #48622 |
Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-java/sessions/bf7036ec-7fdf-46d5-8050-b72f537332d4 Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
…ationProperties Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-java/sessions/f49e9a93-8331-49f4-b8f0-2f78dbb7c32a Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread |
1 similar comment
|
@copilot apply changes based on the comments in this thread |
…or.trustedIssuerRepoValidIssuer
|
@copilot apply changes based on the comments in this thread |
1 similar comment
|
@copilot apply changes based on the comments in this thread |
…ion; add uppercase GUID test Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-java/sessions/065745e5-0b86-4d87-a559-fae10571fc21 Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Fixed in commit |
Fixed in commit
Fixed in commit
These changes were already applied in commit |
This pull request introduces breaking changes to Azure Active Directory (AAD) resource server configuration in the Spring Cloud Azure autoconfigure module, primarily strengthening security by requiring explicit tenant configuration and enforcing audience validation by default. The changes also update related tests and documentation to reflect these new requirements.
Breaking changes to AAD resource server configuration:
spring.cloud.azure.active-directory.profile.tenant-idto be set to a specific, non-reserved tenant ID. Using empty,common,organizations, orconsumersvalues will cause application startup to fail with anIllegalArgumentException. [1]], [2]])AadAuthenticationFilternow enables explicit audience validation by default. JWT tokens must have anaudclaim matching either the configured client ID or App ID URI; tokens for other audiences are rejected. [1]], [2]], [3]])Security improvements:
AadJwtIssuerValidator) now strictly checks that the issuer is in the trusted set for the configured tenant, removing fallback to broad Microsoft endpoints. ([sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/aad/security/jwt/AadJwtIssuerValidator.javaL21-R37])tid) claim check and use the trusted issuer repository for issuer validation. ([sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/aad/configuration/AadResourceServerConfiguration.javaR70-R113])Documentation and error messaging:
Test updates:
These changes enforce best security practices for OAuth2/OIDC resource servers and prevent misconfiguration or cross-application token acceptance.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines