Skip to content

Include per-client cache settings for client credentials tokens in ATM 4.3.x - #373

Merged
pgermishuys merged 1 commit into
releases/atm/4.3.xfrom
pg/atm-4.3-client-cache
Oct 16, 2026
Merged

pgermishuys merged 1 commit into
releases/atm/4.3.xfrom
pg/atm-4.3-client-cache

Conversation

@pgermishuys

@pgermishuys pgermishuys commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Brings #368 to 4.3.x. Apps that use client credentials against more than one authorization server can now set cache auto-tuning, default cache lifetime, lifetime buffer and local cache expiration per client, with ConfigureClientCache and ClientCredentialsClientCacheOptions. Anything left unset falls back to ClientCredentialsTokenManagementOptions, so existing setups behave the same.

Cherry-picked the squash commit of #368 with git cherry-pick -x. One conflict, in ClientCredentialsTokenManager.cs: on main the cache log call also takes the token expiration, which comes from #364 and isn't part of 4.3.x. I kept #368's SetExpiration(cacheKey, token.Expiration, cacheSettings) and the three-argument CachingAccessToken call this branch already has.

Merge order: last of five, after #372. Until the earlier ones merge, this PR also shows their commits.

@pgermishuys pgermishuys added the area/foss/atm Issues related to Access Token Management label Oct 16, 2026
Client credentials token caching was configured only through the global
ClientCredentialsTokenManagementOptions, so every client shared the same
auto-tuning, default lifetime, lifetime buffer and local cache expiration.
Apps that call several authorization servers could not tune these per
server.

Add ClientCredentialsClientCacheOptions, configured as named options keyed
by client name via the new ConfigureClientCache builder method or
services.Configure<ClientCredentialsClientCacheOptions>(name, ...). Each
property is nullable and falls back to the global option when not set, so
existing configurations behave as before.

The token manager resolves the effective settings once per request and
uses them for the auto-tuning store, the local cache expiration and the
expired-token buffer check, so the cache lifetime and the expiry check
always agree. The options type has no validator and is independent of
ClientCredentialsClient, so overrides also work for clients served by a
custom IClientCredentialsTokenEndpoint without AddClient.

(cherry picked from commit 82d44af)
@pgermishuys
pgermishuys force-pushed the pg/atm-4.3-client-cache branch from c928ae8 to 3decfb8 Compare October 16, 2026 12:58
@pgermishuys
pgermishuys changed the base branch from releases/atm/4.3.x to releases/atm/4.2.x October 16, 2026 13:09
@pgermishuys
pgermishuys changed the base branch from releases/atm/4.2.x to releases/atm/4.3.x October 16, 2026 13:10
@pgermishuys
pgermishuys merged commit 3c57a6d into releases/atm/4.3.x Oct 16, 2026
2 checks passed
@pgermishuys
pgermishuys deleted the pg/atm-4.3-client-cache branch October 16, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/foss/atm Issues related to Access Token Management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants