Repository navigation
BREAKING CHANGE: TokenCacheExtensions: Match the used key namings to the TokenCache defaults and standarized official namings - #2893
Closed
DevTKSS wants to merge 21 commits into
Conversation
…che defaults and standarized official namings
…nsAsync method that will allow to use it with own Keys chore: Added Extensions for the other standarized Keys alongside with the relevant const string representations chore: Added to each of the seperate existing methods for e.g. AccessTokenAsync the key name as optional parameter By allowing the key as optional parameter and those new extensions, we will gain more flexibility for the user of it. This will be especially usefull for cases like oAuth where we do not have a id_token then e.g. a user_id that would be important to store instead of that and would represent in this scenario the equivalent to the id_token of jwt.
…che relevant key options and make them availabele as nested Property instead This allows to re-use this options object across all Authentication Extensions and also for any future Extension By making it have a public accessor, this can also be added as part of a CustomAuthenticationOptions object for example.
Found no information if this is needed as its a part of the WebConfiguration object but as there is no json serializer context, for it this should make sure its there at runtime. Seperated this in own commit to be able to drop it if not needed
… user not provides a own key, the old method with default values will be used by default.
This is good to avoid eventually not existing Keys and get rid of duplicated logic for existance checks everywhere
…nProvider token extraction
… the new added FluentBuilder replicating existing code of oidc extension, but fitted to nested Options structure
… keys that the user want to handle himself on the callbacks
It requires so far, to use the seperate method just for that. As it is a kind of normal thing to have tokens expire and the WinUIEx is also using those, it does make sense to enable that.
… this collection he is not able to get on his own, if he dont wants them to be extracted and provided as arguments. TODO: Maybe for this the credentials Dictionary should be used instead?
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces breaking changes to standardize token cache key naming conventions in the authentication system. The changes align the TokenCacheExtensions keys with OAuth2/OpenID Connect standard names and introduce a more flexible token cache configuration system.
Key changes include:
- Changed token cache key constants from PascalCase to snake_case (e.g., "AccessToken" → "access_token")
- Introduced a new TokenCacheOptions configuration system with fluent builder pattern
- Added support for custom token keys and improved flexibility in token handling
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| IDictionaryExtensions.cs | Adds dictionary extension for safe key replacement operations |
| TokenCacheOptionsBuilder.cs | Implements fluent builder pattern for token cache configuration |
| TokenCacheOptions.cs | Defines new configuration record for token cache settings |
| TokenCacheExtensions.cs | Updates key constants and adds new extension methods with customizable keys |
| WebAuthenticationBuilderExtensions.cs | Replaces individual token key methods with unified configuration approach |
| WebConfiguration.cs | Consolidates token-related properties into TokenCacheOptions |
| WebAuthenticationSettings.cs | Updates to use new TokenCacheOptions structure |
| WebAuthenticationProvider.cs | Implements support for OtherTokenKeys and uses new token options |
| HostBuilderExtensions.cs | Adds configuration section binding for TokenCacheOptions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This was referenced Aug 17, 2025
This was referenced Aug 20, 2025
… to uri keys instead chore: seperate TokenCache Keys from Uri Keys and adjust the Configuration and Settings
…ilder type with Action matching existing builder code
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.
GitHub Issue (If applicable): closes #
PR Type
What kind of change does this PR introduce?
What is the current behavior?
access_tokenandrefresh_tokenbut that would be failing if I would not directly set this in the options I am not told about as regular user(!) the WebAuthenticationProvider would always use the Constants with the other casing...OtherTokenKeysare not evaluated at all, the provider does not care about them and the WebConfiguration type couldnt either be gotten throughIOptions<WebConfiguration>so no chance to get them again if used. But we are neither told that they exist at all from the docs. is that because of this not implementation of it?What is the new behavior?
Bugfix / -Prevention
TokenCacheExtensionsdo now match the keys used in the original TokenCacheThis will ensure stability at our Apps runtime and prevent the issue that users of the Extension Methods would not be able to resolve their before stored Tokens by the url parameter names.
Features:
added optional parameters to the SaveTokensAsync method that will allow to use it with own Keys
added Extensions for the other standarized Keys alongside with the relevant const string representations
added to each of the seperate existing methods for e.g. AccessTokenAsync the key name as optional parameter
By allowing the key as optional parameter and those new extensions, we will gain more flexibility for the user of this.
This will be especially usefull for cases like oAuth where we do not have a id_token then e.g. a user_id that would be important to store instead of that and would represent in this scenario the equivalent to the id_token of jwt.
Added Dictionary Extension so in case that we would not have this key in the dictionary so far, we would not run into issues if attempting to add it.
This would also be usefull if the
OtherTokenKeyswould be evaluated to be used at all in the web authAdded Fluent Builder for the
TokenCacheOptionsand implementation in the Hostbuilder Extensions just like the oidc extension already does, but adjusted to its nested structure inWebConfigurationandWebAuthenticationSettingsPR Checklist
Please check if your PR fulfills the following requirements:
Tested code with current supported SDKs
Not sure if
RebuildApp: 44 succeeded, 3 failed, 0 skippedSolution Build result does satisfy your question about "Tested code with current supported SDKs" but here is the Build solution output:Output-Build.txt
Docs have been added/updated which fit documentation template. (for bug fixes / features)
not so far, can do if the changes are okay with the team.
Unit Tests and/or UI Tests for the changes have been added (for bug fixes / features) (if applicable)
Wasm UI Tests are not showing unexpected any differences. Validate PR
Screenshots Compare Test Runresults.Contains NO breaking changes
Associated with an issue (GitHub or internal) partially causing some of my issues to oAuth but maybe not closing them completly
If this PR contains a breaking change, please describe the impact and migration path for existing applications below.
Please note that breaking changes are likely to be rejected
TokenCacheOptionsTypeEndpointOptionsnot just from Extensions own classes then also from the using uno app, so they can be gotten throughtIOptions<TokenCacheOptions>using e.g. the PathWeb:TokenOptionsor also its DefaultName which is defined as const, so we have no need to type it our own then can use that const instead for NamedOptions.OtherTokenKeysprovided in there as theWebAuthenticationProviderdoes now have a foreach loop set up, which is extracting each of the Parameters by its Value provided urlKey.Other information
Internal Issue (If applicable):