Repository navigation
Address review on derive grant checks - #7044
Merged
Merged
Conversation
Refuse a refresh-only exchange_refresh_tokens config at startup: a derived child is capped by id_jag_max_lifetime, so without it every derive is refused. Restore the zero-lifetime boundary rows in TestValidateChildEntry. Check whole-second expiry for the presented grant before any other refusal, so an under-one-second grant always gets grant_invalid. Rename the presented grant from parent to source, keeping parent for the grant's own parent. Co-authored-by: Mecatl <[email protected]>
jhrozek
requested review from
ChrisJBurns,
JAORMX,
amirejaz,
aponcedeleonch,
rdimitrov,
reyortiz3 and
tgrunnagle
as code owners
November 3, 2026 19:57
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7044 +/- ##
==========================================
+ Coverage 80.53% 80.54% +0.01%
==========================================
Files 853 853
Lines 87221 87225 +4
==========================================
+ Hits 70243 70256 +13
+ Misses 16973 16964 -9
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rdimitrov
approved these changes
Nov 4, 2026
rdimitrov
left a comment
Member
There was a problem hiding this comment.
LGTM. The whole-second check now runs before the liveness refusals, and the ErrExpired guard is a strict subset of it, so the order is consistent. The new startup rejection only affects refresh-only configs, which could never derive anyway, and #7007 is not in a release yet (v0.61.0 predates it), so no existing users break.
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
Follow-up to "Derive child exchange grants from refresh tokens" (#7007). It fixes the four review findings on that PR that were held back so the approved head stayed as reviewed.
id_jag_max_lifetime. With onlyrefresh_token_max_lifetimeset, the client got top-level grants it could never derive from, and every derive failed withtoken_type_not_permitted. Validation now rejectsrefresh_token_max_lifetimewithoutid_jag_max_lifetimeat startup.revoked, and a child gotnot_issuable, instead ofgrant_invalidas the docs promise. The check now runs right after the client check, before any other refusal. The test uses a fixed clock, so it pins the order on every run, not about half the time.TestValidateChildEntry. They were removed with the oldparent_expiredreason. They are back, now expectinginvalid_expires_at.parent_revoked). This is a rename in code, tests and docs; behaviour is unchanged.docs/arch/17-token-exchange-delegation.md: the check-order list gets the whole-second step, and the note abouttoken_type_not_permittedafter a config change is corrected (a configured client can no longer reach the missing-cap case).Type of change
Test plan
task test)task test-e2e)task lint-fix)Ran
go build ./pkg/authserver/...andgo test -raceonpkg/authserver/server/tokenexchangeandpkg/authserver/server/registrationagainst the final tree. Both pass. The full suite and lint run in CI.Does this introduce a user-facing change?
Yes, for auth server configuration:
token_exchange.exchange_refresh_tokensset to onlyrefresh_token_max_lifetimestarted normally. Every derive from its grants was then refused withtoken_type_not_permitted.token_exchange.exchange_refresh_tokens.refresh_token_max_lifetime requires id_jag_max_lifetime, because a derived child refresh token is capped by it. Settingid_jag_max_lifetimealone, or both caps, works as before.The field exists only in the RunConfig (there is no CRD for it yet), so no migration is needed.
Also, a presented grant with under one whole second left now always gets
grant_invalid. Before, it could getrevoked,parent_revokedornot_issuable, depending on what else was wrong with it.Special notes for reviewers
storage.ErrExpiredbranch incheckPresentedGrantcan no longer be reached, because the whole-second check refuses every expired grant first. It is kept on purpose as a guard in case that order changes, and its comment says so.TestDeriveChildTypeNotConfiguredFallback(renamed fromTestDeriveChildTypeMustBeConfigured) uses a refresh-only policy that startup now rejects. It is kept on purpose: it pins the refusal for a handler built without config validation.