Skip to content

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
unoplatform:mainfrom
DevTKSS:token-extensions-keys-should-match-standards
Closed

DevTKSS wants to merge 21 commits into
unoplatform:mainfrom
DevTKSS:token-extensions-keys-should-match-standards

Conversation

@DevTKSS

@DevTKSS DevTKSS commented Aug 16, 2025 •

Copy link
Copy Markdown
Contributor

GitHub Issue (If applicable): closes #

PR Type

What kind of change does this PR introduce?

  • Documentation content changes
  • Feature
  • Other... Please describe: Future Bug Prevention!
  • Bugfix

What is the current behavior?

  • Assuming somone would use the TokenCacheExtension defined Extensions, which do not allow for those Keys to provide an alternative, the tokens would not be able to receive using that constants (e.g. I would like to use access_token and refresh_token but 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...
  • The OtherTokenKeys are not evaluated at all, the provider does not care about them and the WebConfiguration type couldnt either be gotten through IOptions<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

  • The keys used by the TokenCacheExtensions do now match the keys used in the original TokenCache
    This 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 OtherTokenKeys would be evaluated to be used at all in the web auth

  • Added Fluent Builder for the TokenCacheOptions and implementation in the Hostbuilder Extensions just like the oidc extension already does, but adjusted to its nested structure in WebConfiguration and WebAuthenticationSettings

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs

    • so far I dont know how exactly to do this the docs are attempting to tell for the uno.ui repo but seems like the Web project does miss packages?
      Not sure if RebuildApp: 44 succeeded, 3 failed, 0 skipped Solution 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)

    • failing to add tests for e.g. the Dictionary Extension in the core extensions project, but thats not possible and causing a circular reference
    • Build of the Solution (without filter) does fail on runtimeTests?
  • Wasm UI Tests are not showing unexpected any differences. Validate PR Screenshots Compare Test Run results.

  • 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

  • AuthenticationBuilderExtensions would be required to be adjusted for the moved Options to the TokenCacheOptions Type
  • the seperated type can be inherited from like the EndpointOptions not just from Extensions own classes then also from the using uno app, so they can be gotten throught IOptions<TokenCacheOptions> using e.g. the Path Web:TokenOptions or 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.
  • We are now able to source the Parameters from the OtherTokenKeys provided in there as the WebAuthenticationProvider does now have a foreach loop set up, which is extracting each of the Parameters by its Value provided urlKey.

Other information

  • needs help to implement tests for this
  • not really seeing the way to "build it locally" from the docs. Without target framework override, so building everything, doesnt that satisfy this point? not sure...

Internal Issue (If applicable):

DevTKSS added 14 commits August 16, 2025 15:27
…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
… 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?
Copilot AI review requested due to automatic review settings August 16, 2025 20:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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.

@DevTKSS DevTKSS closed this Oct 30, 2025
@DevTKSS
DevTKSS deleted the token-extensions-keys-should-match-standards branch December 3, 2025 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants