stacklok / stacklok/toolhive

updateConfigTokenRef uses global config instead of injected provider

Open
#4,123 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

authentication bug go
Dominant language
Go
Stars
2.2k
Forks
300
Avg merge
1d 15h
Merged PRs (30d)
184

Description

Summary

pkg/registry/auth/oauth_token_source.go:updateConfigTokenRef calls the package-level config.UpdateConfig(...) function rather than going through an injected config.Provider interface.

This means the token reference/expiry is always written to the default config file location, even when a non-default config path is in use (e.g., via PathProvider in tests or custom deployments).

Impact

  • In tests using custom config paths, the token reference may be written to the wrong file
  • Inconsistent with the rest of the auth flow which properly uses injected config.Provider

Suggested Fix

Pass a config.Provider into the oauthTokenSource constructor (or pass an updateFn func(func(*config.Config)) error callback), and use it in updateConfigTokenRef instead of the global function.

Context

Found during review of #4121 (registry login/logout CLI commands).

🤖 Generated with Claude Code

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in pkg/registry/auth/oauth_token_source.go at updateConfigTokenRef and trace the oauthTokenSource constructor and existing config.Provider usage in the auth flow. Reproduce the behavior with a non-default config path such as the PathProvider setup mentioned in the issue. Done means the token reference and expiry are written through the injected provider, with coverage for the custom path.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
authentication, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.