Repository navigation
Let delegate clients change policy on restart - #6918
Merged
Merged
Conversation
Since #6473 (v0.47.0), changing a delegate client's scopes or audiences on Redis failed startup with "already registered as a different configured client". In Kubernetes the new pod never became ready and the rollout stuck until someone deleted the Redis row by hand. Before #6473, delegates were registered with an unconditional write, so this is a regression. ReconcileConfiguredClient now decides by client kind. A delegate client replaces its stored row, unless the public/confidential class flips, and a scope or audience change logs a WARN with the old and new values. SPIFFE placeholders keep the strict fingerprint check, as the #6473 review required, and a placeholder and a non-placeholder never replace each other. Both backends share one decision function. fingerprintOfClient now reads resources and identity only for reserved placeholders, matching what the Redis backend stores. On Redis the row is shared, so the last replica to start wins. During a rollout with two configs, replicas can serve either policy, and narrowing a delegate is not a reliable revocation until no old-config pod restarts. An older binary (v0.47.0 or later) fails to start against a row this change replaced with a different policy, so a rollback needs the old policy written back first, or the row deleted. Adds unit tests for both backends, an in-process restart test against a shared Redis, and a kind e2e for the rollout (not yet run). Updates the auth server storage, SPIFFE and Redis storage docs. Co-authored-by: Mecatl <[email protected]>
jhrozek
force-pushed
the
configured-client-reconcile
branch
from
October 22, 2026 11:43
9e86bc1 to
c3cd8ee
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6918 +/- ##
==========================================
+ Coverage 79.79% 79.86% +0.06%
==========================================
Files 828 828
Lines 84632 84668 +36
==========================================
+ Hits 67534 67616 +82
+ Misses 17093 17047 -46
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jhrozek
marked this pull request as ready for review
October 22, 2026 12:51
jhrozek
requested review from
ChrisJBurns,
JAORMX,
amirejaz,
blkt,
jerm-dro,
rdimitrov,
reyortiz3 and
tgrunnagle
as code owners
October 22, 2026 12:51
ChrisJBurns
approved these changes
Oct 22, 2026
1 task
3 tasks done
jhrozek
added a commit
that referenced
this pull request
Oct 28, 2026
Delegate clients could only be secret-authenticated, token-exchange-only clients. Issue #6893 needs a pre-provisioned broker that keeps its client_id across key rotation, so the config now accepts an auth method, a JWKS file, grant types and redirect URIs. One validator in the registration package checks these fields and shares the DCR private_key_jwt key check. It runs on RunConfig (keys not yet loaded), on the resolved Config (keys loaded) before any client is registered, and when the client is built. Redirect URIs follow the confidential-client rule: https, not loopback. refresh_token requires authorization_code, as in DCR. The constructor keeps today's bare client for default inputs and never marks the result as DCR-issued. Every delegate client still counts as confidential for the cleartext-transport check, private_key_jwt ones included. They send no reusable secret, but unlike token-exchange-only DCR private_key_jwt clients they can hold authorization_code and refresh_token, so codes and tokens would cross plain HTTP. This matches the CRD rules and can be relaxed later if an in-cluster HTTP issuer is needed. The transport errors now name both triggers instead of only confidential registration. Replacing a configured client now also logs the WARN from #6918 when its grant types, redirect URIs or auth method change. A JWKS change is key rotation and stays silent. The runner does not load the JWKS file or pass the new fields yet; the next change in the stack wires them, and the two are meant to land together. Co-authored-by: Mecatl <[email protected]>
jhrozek
added a commit
that referenced
this pull request
Oct 28, 2026
Delegate clients could only be secret-authenticated, token-exchange-only clients. Issue #6893 needs a pre-provisioned broker that keeps its client_id across key rotation, so the config now accepts an auth method, a JWKS file, grant types and redirect URIs. One validator in the registration package checks these fields and shares the DCR private_key_jwt key check. It runs on RunConfig (keys not yet loaded), on the resolved Config (keys loaded) before any client is registered, and when the client is built. Redirect URIs follow the confidential-client rule: https, not loopback. refresh_token requires authorization_code, as in DCR. The constructor keeps today's bare client for default inputs and never marks the result as DCR-issued. Every delegate client still counts as confidential for the cleartext-transport check, private_key_jwt ones included. They send no reusable secret, but unlike token-exchange-only DCR private_key_jwt clients they can hold authorization_code and refresh_token, so codes and tokens would cross plain HTTP. This matches the CRD rules and can be relaxed later if an in-cluster HTTP issuer is needed. The transport errors now name both triggers instead of only confidential registration. Replacing a configured client now also logs the WARN from #6918 when its grant types, redirect URIs or auth method change. A JWKS change is key rotation and stays silent. The runner does not load the JWKS file or pass the new fields yet; the next change in the stack wires them, and the two are meant to land together. Co-authored-by: Mecatl <[email protected]>
jhrozek
added a commit
that referenced
this pull request
Oct 28, 2026
Delegate clients could only be secret-authenticated, token-exchange-only clients. Issue #6893 needs a pre-provisioned broker that keeps its client_id across key rotation, so the config now accepts an auth method, a JWKS file, grant types and redirect URIs. One validator in the registration package checks these fields and shares the DCR private_key_jwt key check. It runs on RunConfig (keys not yet loaded), on the resolved Config (keys loaded) before any client is registered, and when the client is built. Redirect URIs follow the confidential-client rule: https, not loopback. refresh_token requires authorization_code, as in DCR. The constructor keeps today's bare client for default inputs and never marks the result as DCR-issued. Every delegate client still counts as confidential for the cleartext-transport check, private_key_jwt ones included. They send no reusable secret, but unlike token-exchange-only DCR private_key_jwt clients they can hold authorization_code and refresh_token, so codes and tokens would cross plain HTTP. This matches the CRD rules and can be relaxed later if an in-cluster HTTP issuer is needed. The transport errors now name both triggers instead of only confidential registration. Replacing a configured client now also logs the WARN from #6918 when its grant types, redirect URIs or auth method change. A JWKS change is key rotation and stays silent. The runner does not load the JWKS file or pass the new fields yet; the next change in the stack wires them, and the two are meant to land together. Co-authored-by: Mecatl <[email protected]>
jhrozek
added a commit
that referenced
this pull request
Oct 28, 2026
Delegate clients could only be secret-authenticated, token-exchange-only clients. Issue #6893 needs a pre-provisioned broker that keeps its client_id across key rotation, so the config now accepts an auth method, a JWKS file, grant types and redirect URIs. One validator in the registration package checks these fields and shares the DCR private_key_jwt key check. It runs on RunConfig (keys not yet loaded), on the resolved Config (keys loaded) before any client is registered, and when the client is built. Redirect URIs follow the confidential-client rule: https, not loopback. refresh_token requires authorization_code, as in DCR. The constructor keeps today's bare client for default inputs and never marks the result as DCR-issued. Every delegate client still counts as confidential for the cleartext-transport check, private_key_jwt ones included. They send no reusable secret, but unlike token-exchange-only DCR private_key_jwt clients they can hold authorization_code and refresh_token, so codes and tokens would cross plain HTTP. This matches the CRD rules and can be relaxed later if an in-cluster HTTP issuer is needed. The transport errors now name both triggers instead of only confidential registration. Replacing a configured client now also logs the WARN from #6918 when its grant types, redirect URIs or auth method change. A JWKS change is key rotation and stays silent. The runner does not load the JWKS file or pass the new fields yet; the next change in the stack wires them, and the two are meant to land together. Co-authored-by: Mecatl <[email protected]>
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.
Summary
Since #6473 (v0.47.0), changing a delegate client's
scopesoraudienceson Redis storage fails startup withclient "<id>" is already registered as a different configured client. In Kubernetes the new pod never becomes Ready and the rollout stays stuck until someone deletes the Redis row by hand. Before #6473, delegates were written with an unconditionalSET, so this is a regression. The strict check came from the #6473 review for SPIFFE placeholders. Delegate clients were never discussed there and picked it up as a side effect. The configured broker clients in #6893 need this fixed first, because their grants change routinely.ReconcileConfiguredClientnow decides by client kind, through one shared function,configuredClientConflictinpkg/authserver/storage/types.go, used by both the memory and Redis backends:configured client replaced with a different policy, withclient_idand the old and new values. Secrets are never logged.fingerprintOfClientnow reads resources and SPIFFE identity only for reserved placeholders, matching what the Redis backend stores, so both backends compare the same inputs.docs/arch/11-auth-server-storage.mdgets a new "Configured clients across restarts" section.17-token-exchange-delegation.md,18-spiffe-association-declarations.mdanddocs/redis-storage.mdare updated to match.Fixes #6906
Type of change
Test plan
Unit tests (
task test)E2E tests (
task test-e2e)Linting (
task lint)Manual testing (describe below)
Unit tests: a shared table runs the conflict rules against both backends (memory and miniredis). There are also Redis-only cases:
In-process integration test:
TestConfiguredDelegateClientPolicyChangeAcrossRestartsrestarts a real embedded auth server against one shared miniredis. It checks that:Kind e2e:
virtualmcp_delegate_clients_redis_test.goedits a delegate's scopes on a Redis-backed VirtualMCPServer. It waits for the rollout and checks that the new scopes are enforced. It runs in CI's operator e2e job. It was not run locally; it compiles (task lintrunsgo vetover it).Changes
pkg/authserver/storage/types.goconfiguredClientConflict,policyChanged,warnConfiguredClientReplaced;reservedfield onclientFingerprint;fingerprintOfClientreads resources and identity only for placeholders; contract docpkg/authserver/storage/memory.gopkg/authserver/storage/redis.gopkg/authserver/storage/spiffe_decorator.gopkg/authserver/storage/*_test.gopkg/authserver/delegate_client_restart_integration_test.gotest/e2e/thv-operator/virtualmcp/virtualmcp_delegate_clients_redis_test.godocs/arch/11-*.md,17-*.md,18-*.md,docs/redis-storage.mdDoes this introduce a user-facing change?
Yes.
Unchanged:
The memory backend was never affected.
Special notes for reviewers
Deliberate deviation: SPIFFE placeholders keep the strict check. In the Normalize canonical inbound grants #6473 review (2026-09-04), @JAORMX asked for the policy to be part of the placeholder fingerprint, to block rolling policy changes:
SPIFFE clients are served from each replica's own config, so the strict check still makes sense there. Delegate clients are served from the shared Redis row, so the same check only blocks the rollout. The SPIFFE edit problem is tracked separately in Editing a SPIFFE client association on Redis storage leaves the new pod never ready #6907.
Accepted trade-off: rolling updates on Redis. The delegate row is shared and read on every token request.
audienceparameter, come from the shared row alone. Aresourceparameter and the default audience are still checked against each replica's ownallowedAudiences.docs/arch/11-auth-server-storage.md.Rollback. An older binary (v0.47.0 or later) fails startup against a row this change replaced with a different policy. To roll back across a delegate policy edit, do one of these:
No new stored field was added, so older binaries can still read the rows. This is documented in the same section.
Grant types are not compared for delegate clients, and a grant change doesn't trigger the WARN. Delegate grants are fixed in code today. If they become configurable (Stable pre-provisioned broker client for token exchange and ID-JAG redemption #6893), revisit
policyChanged.Known limits, not fixed here:
Existing tests whose expectations changed:
TestMemoryStorage_ReconcileConfiguredClientandTestRedisStorage_ReconcileConfiguredClient: the "refuses a different configured client at the same ID" subtests are removed. The shared table covers replacement now.TestSPIFFEStorageDecoratorRejectsDifferentConfiguredClientCollision: the comment is corrected. It seeds a non-placeholder client and now fails on the kind check.Approved implementation plan (decided design)
In
ReconcileConfiguredClient, on both backends, when an existing row is found:clientFromStored's legacy-row handling.publicdiffers. A confidential-to-public flip would let refresh tokens issued to a confidential client be used without a secret. Otherwise the row is replaced: TTL 0 andZRemfrom the DCR cap index, as today.slog.Warnwithclient_idand the old and new scopes and audiences. The secret is never logged.Symmetry fix:
fingerprintOfClientreads resources and identity only whenisReservedPlaceholder(c), matchingbuildStoredClient. There is no new stored field and no migration.