Move tokenexchange under pkg/oauthproto#5251
Merged
Merged
Conversation
Relocate pkg/auth/tokenexchange to pkg/oauthproto/tokenexchange so the RFC 8693 Token Exchange grant sits next to the shared grant-helper primitives (pkg/oauthproto/grants.go, pkg/oauthproto/oauthtest) and the upcoming RFC 7523 JWT Bearer grant. With the refactor complete, pkg/oauthproto is the single home for OAuth 2.0 grant machinery in this repo; having one grant under pkg/auth and another under pkg/oauthproto would have been confusing. Pure rename. All source files move intact; every import path updated from github.com/stacklok/toolhive/pkg/auth/tokenexchange to github.com/stacklok/toolhive/pkg/oauthproto/tokenexchange. Also updated stale doc and agent references to the old path in docs/middleware.md, docs/operator/crd-api.md, and .claude/agents/oauth-expert.md. Regenerated docs/server/ swagger so the schema component key reflects the new import path. The wire format of tokenexchange.Config is unchanged; only the OpenAPI $ref key (a swaggo artifact derived from the Go import path) differs. task test and task lint-fix are clean.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5251 +/- ##
==========================================
- Coverage 68.02% 67.99% -0.04%
==========================================
Files 615 615
Lines 62960 62960
==========================================
- Hits 42829 42807 -22
- Misses 16929 16952 +23
+ Partials 3202 3201 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
rdimitrov
approved these changes
May 11, 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
pkg/auth/tokenexchangeis relocated topkg/oauthproto/tokenexchangesoall RFC-defined OAuth 2.0 grant machinery lives in one place alongside the
existing grant helpers (
grants.go,oauthtest). Having the RFC 8693token-exchange grant under
pkg/authwhile other grant primitives live underpkg/oauthprotowas inconsistent and would have grown more confusing asadditional grant types land.
Type of change
Test plan
task testpassestask lint-fixpassespkg/auth/tokenexchangereferences remain (verified by grep across all.go,.md,.yaml,.jsonfiles)Does this introduce a user-facing change?
No.
Special notes for reviewers
The regenerated
docs/server/swagger files are included. The OpenAPI schemacomponent key changed from
github_com_stacklok_toolhive_pkg_auth_tokenexchange.Configto
github_com_stacklok_toolhive_pkg_oauthproto_tokenexchange.Config— this isa swaggo artifact derived from the Go import path. The wire format of
tokenexchange.Configis unchanged.Generated with Claude Code