refactor(token): collapse token provider to concrete type#235
Merged
Conversation
- Remove the TokenProvider and IDTokenProvider interfaces in favor of the single concrete LocalTokenProvider - Inject the concrete provider directly into services, bootstrap, and the JWKS handler - Replace the ID token provider type assertion with a direct method call - Delete the unused generated token provider mock and its generate directive - Update architecture docs and guidelines to describe the concrete provider
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the unused core.TokenProvider / core.IDTokenProvider interface layer and updates the codebase to inject/use the single concrete implementation (*token.LocalTokenProvider) everywhere. This simplifies the token issuance and JWKS/ID-token capability wiring without changing token behavior or external APIs.
Changes:
- Deleted
core.TokenProviderandcore.IDTokenProvider(and the unused generated GoMock token mocks). - Updated services/bootstrap/handlers to depend on
*token.LocalTokenProviderdirectly (including JWKS + ID-token support wiring). - Updated docs to reflect that token generation is intentionally concrete (not pluggable via interface).
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/token/local.go | Removes now-dead interface assertion/import; keeps provider concrete. |
| internal/token/idtoken.go | Removes re-export of the removed IDTokenProvider alias; keeps IDTokenParams alias. |
| internal/services/token.go | Changes TokenService to hold *token.LocalTokenProvider instead of core.TokenProvider. |
| internal/services/token_exchange.go | Removes optional ID-token-provider assertion and calls GenerateIDToken directly under openid scope gate. |
| internal/mocks/mock_token.go | Deletes unused generated mocks for the removed interfaces. |
| internal/mocks/generate.go | Removes the go:generate directive for the deleted token mocks. |
| internal/core/token.go | Removes the interfaces; keeps shared param/result structs in core. |
| internal/bootstrap/services.go | Updates service initialization wiring to accept *token.LocalTokenProvider. |
| internal/bootstrap/handlers.go | JWKS handler now built directly from LocalTokenProvider; ID-token support flag set to true. |
| internal/bootstrap/bootstrap.go | Updates Application.TokenProvider field type to *token.LocalTokenProvider. |
| docs/ARCHITECTURE.md | Updates architecture docs to describe the concrete token provider and its RFC 8707-shaped signatures. |
| CLAUDE.md | Updates contributor guidance to reflect “intentionally concrete” token provider design. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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
Removes the
core.TokenProvider/core.IDTokenProviderinterface abstraction and collapses every consumer onto the single concrete*token.LocalTokenProvider. There was exactly one implementation and the only other "implementation" — the generatedMockTokenProvider— was completely unused (every test constructs a realtoken.NewLocalTokenProvider). This is a pure internal refactor: no config, API, or token-output change.AI Authorship
Change classification
Core code (broad impact — needs line-by-line review)
Touches the token-issuance path (
internal/core/token.go,internal/token/,internal/services/token*.go). Although behavior is unchanged, this is the auth/token-signing core, so the stricter review bar applies.Plan reference
Executed from
plan.md— "Remove the pluggableTokenProviderinterface (collapse to concreteLocalTokenProvider)". Goal: the interface abstraction is gone, every consumer holds the concrete provider, the dead mock is deleted, docs no longer describe a pluggable token backend, andmake generate && build && test && lintall pass with no behavior change to issued tokens.Verification
make testgreen;services,bootstrap,token,corere-run individually green)make generate && make build && make lintall pass (lint: 0 issues)authorization_code+openid(token-exchange tests)PublicKey()→ nil)aud/scopegrep -rn "core.TokenProvider\|core.IDTokenProvider\|MockTokenProvider" --include="*.go" .→ no matches.Verifiability check
Security check
Pure internal refactor — no external interface, input-validation, or auth-decision change. No secrets in the diff. The
typeclaim /audbinding logic and signing code (token/local.go) are untouched except for removing a deadvar _ core.TokenProviderassertion and an unused import.Risk & rollback
git revertrestores the interface.Reviewer guide
internal/services/token_exchange.go— the ID-token block lost itscore.IDTokenProvidertype assertion; theif scopeSet := …; scopeSet["openid"]guard was re-indented (confirm the re-indent is behavior-preserving).internal/core/token.go— confirm only the two interfaces were deleted; the four result/param structs are kept.internal/bootstrap/handlers.go—buildJWKSHandlernow calls the concreteAlgorithm()/KeyID()/PublicKey();NewOIDCHandleris passed a literaltruefor ID-token support (the bool param is now vestigial — noted as a follow-up, not changed here).core.TokenProvider→*token.LocalTokenProviderretypes inbootstrap/{bootstrap,services}.go,services/token.go,token/idtoken.go,token/local.go; themock_token.godeletion +generate.godirective removal; the CLAUDE.md / ARCHITECTURE.md doc updates.🤖 Generated with Claude Code