Repository navigation
[AAD][Boot 3] Allow anonymous access to the client credentials sample API - #869
Draft
Moary Chen (moarychan) wants to merge 2 commits into
Draft
Moary Chen (moarychan) wants to merge 2 commits into
Moary Chen (moarychan) wants to merge 2 commits into
Conversation
Port the final net changes from #868 (26407f1), adapting the test starter and AutoConfigureMockMvc package to Spring Boot 3. Preserve existing framework versions and method permissions without bringing over superseded README changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The anonymous-access backport has no active review issues.
No open issues 🎉
What changed in this PR
Backports the anonymous-access fix to the Spring Boot 3 AAD resource-server sample, keeping /webapiB/clientCredential public while protecting other requests.
Changes:
- Adds a sample-owned security chain with an authenticated fallback and method-level security.
- Adds eight authorization test cases using MockMvc and a mocked
JwtDecoder. - Adds the Boot 3-compatible test starter without changing runtime dependency versions.
| File | Description |
|---|---|
| aad/spring-cloud-azure-starter-active-directory/web-client-access-resource-server/aad-resource-server/src/test/java/com/azure/spring/sample/aad/security/AadResourceServerConfigTests.java | Tests anonymous access, authentication requirements, and scope enforcement. |
| aad/spring-cloud-azure-starter-active-directory/web-client-access-resource-server/aad-resource-server/src/main/java/com/azure/spring/sample/aad/security/AadResourceServerConfig.java | Configures the public endpoint exception and protects remaining requests. |
| aad/spring-cloud-azure-starter-active-directory/web-client-access-resource-server/aad-resource-server/pom.xml | Adds test-scoped spring-boot-starter-test. |
Review effort: Balanced
Contributor
Author
|
Copilot merge main branch to sync code |
Contributor
The merge preview shows 74 conflicts: |
Contributor
Author
|
Copilot Sorry, merge |
…backport-868-aad-authentication-spring-boot-3x Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Contributor
Moary Chen (moarychan)
marked this pull request as draft
November 27, 2026 07:22
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.
Purpose
Backport the final changes from #868 to
spring-boot-3.x.Explicitly allow anonymous access to
/webapiB/clientCredentialwhile requiring authentication for other requests and preserving the existing method-level scope checks.Source:
26407f1893bf688bda4f75eea0013ec5fca5d81a. Only the source PR's final three-file net change is included; its superseded README changes are not ported.Changes and Boot 3 adaptations
permitAll()for the public endpoint, with an authenticated fallback and method security.spring-boot-starter-testinstead of Boot 4'sspring-boot-starter-webmvc-test.org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc.@MockitoBean, which is available in the target Spring Framework version.3.5.16, Spring Cloud Azure6.5.0, and Java 17 compilation.No README, runtime dependency version, controller, mixed Web/API, OBO, or Web application change is included.
/api/hellois retained.Does this introduce a breaking change?
The public sample endpoint remains callable anonymously. The existing protected REST endpoints retain their authentication and scope requirements.
Pull Request Type
How to Test
From the
aad-resource-servermodule:mvn -B -ntp -Dtest=AadResourceServerConfigTests testLocal validation:
permitAll()rule makes the anonymous-endpoint test fail precisely withStatus expected:<200> but was:<401>; restoring it makes the complete class pass.javapverified the target annotation and AAD configurer APIs.git diff --checkpassed.What to Check
GET /webapiB/clientCredentialGET /webapiB,/user, or another non-public pathTests use synthetic properties and a mocked
JwtDecoder. They verify authorization, not real Entra token signatures or OBO exchanges. No full-repository build or live tenant validation was performed.