Repository navigation
Put the authorization details reachability rule in one place - #7281
Merged
Merged
Conversation
A registry for authorization_details is refused at startup when no enabled grant could reach it. The rule was written out three times: in Config validation and at two points in the embedded runner. The JWT-bearer grant is about to become a second consumer of the registry, so the rule should change in one place. Add AuthorizationDetailsRegistryReachable and the sentinel ErrAuthorizationDetailsRegistryUnreachable, and use them at all three sites. The rule is still "token exchange is enabled" and the error text is unchanged, so behaviour is the same. The runner tests now cover accepted configs as well as the refusal, pin the early RunConfig check on its own, and pass the subtest's testing.T to the storage constructor so cleanup runs per subtest. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7281 +/- ##
==========================================
- Coverage 81.86% 81.85% -0.02%
==========================================
Files 915 915
Lines 92868 92870 +2
==========================================
- Hits 76029 76016 -13
- Misses 16834 16849 +15
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jhrozek
approved these changes
Nov 24, 2026
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
An
authorization_detailsregistry is refused at startup when no enabled grant could ever reach it. Today that rule ("the registry needs token exchange") is written out three times: inConfig.Validateand at two points in the embedded runner. "Authorization server: narrow a JWT-bearer access token to one MCP call with authorization_details" (#7061) will make the JWT-bearer grant a second consumer of the registry, so the rule has to change, and it should change in one place rather than three.authserver.AuthorizationDetailsRegistryReachable(tokenExchangeEnabled bool) bool, the single rule for when a registry is reachable. Today it is true only when token exchange is enabled, which is exactly the existing check.authserver.ErrAuthorizationDetailsRegistryUnreachable, with the existing text "authorization details registry requires token exchange to be enabled".Config.validateAuthorizationDetailsRegistryReachable(renamed fromvalidateAuthorizationDetailsRequiresTokenExchange),newEmbeddedAuthServerWithStorage, andvalidateAuthorizationDetailsRegistryForRunConfig.docs/arch/17-token-exchange-delegation.md.Part of #7061. A later change adds the JWT-bearer half of the rule (a registry is also reachable when a trusted issuer has a JWT-bearer policy) and updates the error text with it.
Type of change
Test plan
task test)task lint-fix)New and ported tests:
TestAuthorizationDetailsRegistryReachable(pkg/authserver/config_test.go): a table over the rule, plus a check thatConfigvalidation returns the sentinel. The registry fixture is now shared withTestConfigValidate, whose existing row now matches the full error text.TestEmbeddedAuthServer_AuthorizationDetailsRegistryReachability(renamed from..._RequiresTokenExchange) runs both constructors against three inbound-grant shapes: an empty block (token exchange off, refused with the sentinel before upstream discovery), no block (the legacy default, token exchange on, accepted) and an explicittoken_exchangeblock (accepted). The accepted rows are new; before, only the refusal was tested.TestValidateAuthorizationDetailsRegistryForRunConfigtests the earlyRunConfigcheck on its own. Without it, theNewEmbeddedAuthServerrefusal row would still pass if that check were removed, becausenewEmbeddedAuthServerWithStoragerefuses the same config later, after storage is created.Also ran
go test -race ./pkg/authserver/...andgolangci-lint run ./pkg/authserver/...on the final tree.Changes
pkg/authserver/config.goAuthorizationDetailsRegistryReachable, renamed validatorpkg/authserver/runner/embeddedauthserver.godocs/arch/17-token-exchange-delegation.mdpkg/authserver/config_test.go,pkg/authserver/runner/embeddedauthserver_test.goDoes this introduce a user-facing change?
No. The refusal happens under the same conditions, at the same point in startup, with the same message. Embedders can now also match it with
errors.Is(err, authserver.ErrAuthorizationDetailsRegistryUnreachable); before, it was an unwrappedfmt.Errorfwith no sentinel.Special notes for reviewers
AuthorizationDetailsRegistryReachabletakes aboolrather than aConfigorRunConfigbecause the two callers compute "token exchange on" differently:ConfigfromDisableTokenExchange, the runner fromNormalizeInboundGrants. Today its body is justreturn tokenExchangeEnabled; it exists so the JWT-bearer half lands as one change to one function signature, and the compiler then points at every caller.*testing.T. Before, it captured the parent test'st, so the memory storage was closed only when the whole parent test finished.🤖 Generated with Claude Code