[release/8.0] Extract IsAuthenticated helper method - #68657
Open
Youssef1313 with Copilot wants to merge 1 commit into
Open
[release/8.0] Extract IsAuthenticated helper method#68657Youssef1313 with Copilot wants to merge 1 commit into
Youssef1313 with Copilot wants to merge 1 commit into
Conversation
Co-authored-by: Youssef1313 <31348972+Youssef1313@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
Youssef1313
August 20, 2026 04:26
View session
Contributor
|
Hi @copilot. Please make sure you've updated the PR description to use the Shiproom Template. Also, make sure this PR is not marked as a draft and is ready-to-merge. To learn more about how to prepare a servicing PR click here. |
Contributor
There was a problem hiding this comment.
Pull request overview
Backports a shared SecurityHelper.IsAuthenticated implementation to release/8.0 and updates call sites to use aggregate “any identity authenticated” semantics, aligning output-caching and other features with authorization behavior.
Changes:
- Added
SecurityHelper.IsAuthenticated(ClaimsPrincipal?)with aggregate identity semantics plus unit tests. - Updated
DenyAnonymousAuthorizationRequirement, OutputCachingDefaultPolicy, and Blazor Server revalidation logic to use the shared helper. - Linked the shared helper into additional projects via
.csprojcompile includes, and added OutputCaching regression tests.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Shared/test/Shared.Tests/SecurityHelperTests.cs | Adds unit tests covering null/no identities and non-primary authenticated identity scenarios. |
| src/Shared/SecurityHelper/SecurityHelper.cs | Introduces shared IsAuthenticated helper with aggregate identity semantics. |
| src/Security/Authorization/Core/src/Microsoft.AspNetCore.Authorization.csproj | Includes shared SecurityHelper sources in the Authorization Core build. |
| src/Security/Authorization/Core/src/DenyAnonymousAuthorizationRequirement.cs | Uses shared SecurityHelper.IsAuthenticated to match authorization semantics. |
| src/Middleware/OutputCaching/test/OutputCachePolicyProviderTests.cs | Adds regression tests to ensure authenticated (including non-primary identity) disables output caching. |
| src/Middleware/OutputCaching/src/Policies/DefaultPolicy.cs | Switches authenticated checks to shared helper for request/response phases. |
| src/Middleware/OutputCaching/src/Microsoft.AspNetCore.OutputCaching.csproj | Includes shared SecurityHelper sources in the OutputCaching build. |
| src/Components/Server/src/Microsoft.AspNetCore.Components.Server.csproj | Includes shared SecurityHelper sources in the Components Server build. |
| src/Components/Server/src/Circuits/RevalidatingServerAuthenticationStateProvider.cs | Uses shared helper when deciding whether to enter the revalidation loop. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
4
to
7
| using Microsoft.AspNetCore.Http; | ||
| using System.Security.Claims; | ||
| using Microsoft.Extensions.Logging.Testing; | ||
| using Microsoft.Net.Http.Headers; |
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/8.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