Repository navigation
[release/9.0] Extract IsAuthenticated helper method - #68659
Merged
Merged
Conversation
Co-authored-by: Youssef1313 <31348972+Youssef1313@users.noreply.github.com>
Youssef1313
marked this pull request as ready for review
August 20, 2026 04:40
Contributor
There was a problem hiding this comment.
Pull request overview
This PR backports a bugfix to release/9.0 that centralizes the “is authenticated” check into a shared SecurityHelper.IsAuthenticated(ClaimsPrincipal?) helper and updates call sites to use aggregate identity semantics (i.e., any authenticated identity qualifies), matching authorization behavior.
Changes:
- Add
SecurityHelper.IsAuthenticated(ClaimsPrincipal?)with aggregate identity semantics. - Replace primary-identity-only checks with the new helper in authorization, output caching, and Blazor server revalidation.
- Add unit tests covering multi-identity principals (including authenticated non-primary identity) for both the helper and output caching behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Shared/test/Shared.Tests/SecurityHelperTests.cs | Adds unit tests for SecurityHelper.IsAuthenticated including non-primary authenticated identity case. |
| src/Shared/SecurityHelper/SecurityHelper.cs | Introduces centralized IsAuthenticated helper using aggregate identity semantics. |
| src/Security/Authorization/Core/src/Microsoft.AspNetCore.Authorization.csproj | Links the shared SecurityHelper source into the Authorization assembly. |
| src/Security/Authorization/Core/src/DenyAnonymousAuthorizationRequirement.cs | Switches to SecurityHelper.IsAuthenticated to determine authenticated users. |
| src/Middleware/OutputCaching/test/OutputCachePolicyProviderTests.cs | Adds regression tests ensuring authenticated users (including via non-primary identity) are not cached. |
| src/Middleware/OutputCaching/src/Policies/DefaultPolicy.cs | Uses the helper for both request- and response-phase authenticated checks. |
| src/Middleware/OutputCaching/src/Microsoft.AspNetCore.OutputCaching.csproj | Links the shared SecurityHelper source into the OutputCaching assembly. |
| src/Components/Server/src/Microsoft.AspNetCore.Components.Server.csproj | Links the shared SecurityHelper source into the Components Server assembly. |
| src/Components/Server/src/Circuits/RevalidatingServerAuthenticationStateProvider.cs | Uses the helper for authentication detection before starting the revalidation loop. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
wtgodbe
approved these changes
Sep 2, 2026
This was referenced Oct 13, 2026
Merged
Closed
This was referenced Oct 26, 2026
Open
Open
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.
Backporting #68645 to release/9.0
Extract IsAuthenticated helper method
Centralize IsAuthenticated implementation and use it in all places that need it.
Description
Some callsites didn't have an accurate implementation. So this is a bugfix. The check was also added in the past in servicing.
Fixes #68474
Customer Impact
A claims principal with multiple identities when the first identity is not authenticated but another identity is authenticated would have been considered as not authenticated. With the fix, we look at all identities and consider it authenticated when any identity is authenticated.
Regression?
No
Risk
Low. The change is straightforward and in an area that was touched in servicing in the past.
Verification
Automated. Added unit tests for that.
Packaging changes reviewed?
N/A