Skip to content

Fix cache key isolation by user identity in MvcCachedApplicationConfigurationClient#24990

Merged
EngincanV merged 4 commits intorel-10.0from
fix/mvc-cached-config-client-cache-key-by-user
Mar 2, 2026
Merged

Fix cache key isolation by user identity in MvcCachedApplicationConfigurationClient#24990
EngincanV merged 4 commits intorel-10.0from
fix/mvc-cached-config-client-cache-key-by-user

Conversation

@maliming
Copy link
Member

@maliming maliming commented Mar 2, 2026

Summary

  • Include user identity and UI culture in the httpContext.Items cache key for MvcCachedApplicationConfigurationClient
  • Previously, a fixed key (ApplicationConfigurationDto_CacheKey) was used to cache the distributed cache key in httpContext.Items. If the service was called before authentication middleware, it would cache an anonymous key and reuse it after the user was authenticated, leading to wrong configuration being served
  • Now uses ApplicationConfigurationDto_{userId}_{culture}_CacheKey format, so different authentication states and cultures naturally use different Items keys and don't interfere with each other
  • Extract GetHttpContextItemsCacheKey helper method to avoid duplication between GetAsync and Get`

Copilot AI review requested due to automatic review settings March 2, 2026 06:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a per-request caching bug in MvcCachedApplicationConfigurationClient by ensuring the HttpContext.Items key used to store the distributed-cache key is isolated by user identity, preventing an “anonymous” key computed pre-authentication from being reused after authentication.

Changes:

  • Replace the fixed HttpContext.Items key with a formatted key that includes the current user id (or Anonymous).
  • Apply the new per-user Items key in both async (GetAsync) and sync (Get) code paths.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

@maliming maliming requested a review from EngincanV March 2, 2026 07:28
@EngincanV EngincanV merged commit 3ba9010 into rel-10.0 Mar 2, 2026
3 checks passed
@EngincanV EngincanV deleted the fix/mvc-cached-config-client-cache-key-by-user branch March 2, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants