Skip to content

Use scoped secrets provider for registry auth#4893

Merged
eleftherias merged 3 commits intomainfrom
fix-registry-list
Apr 16, 2026
Merged

Use scoped secrets provider for registry auth#4893
eleftherias merged 3 commits intomainfrom
fix-registry-list

Conversation

@eleftherias
Copy link
Copy Markdown
Member

Summary

  • thv registry login stores tokens under the scoped key __thv_registry_REGISTRY_OAUTH_<hash>, but resolveTokenSource in the factory and newSecretsProvider in the API handler both used the bare CreateSecretProvider. The bare provider looks up REGISTRY_OAUTH_<hash> directly, finds nothing, and falls back to a new OAuth flow — prompting the browser again even though the user just logged in.
  • Switch both call sites to CreateProvider(..., WithScope(ScopeRegistry)) so token reads go to the scoped namespace, with ScopedProvider.GetSecret's bare-key fallback covering the migration window.
  • Fix EncryptedManager.DeleteSecret to return the ErrSecretNotFound sentinel (matching GetSecret) so callers using IsNotFoundError handle delete-not-found correctly.

Fixes #4892

Type of change

  • Bug fix

Test plan

  • Manual testing (describe below)

thv registry login followed by thv registry list no longer re-opens the browser OAuth flow.

Generated with Claude Code

After secret scope migration runs, registry tokens are moved from bare
keys (REGISTRY_OAUTH_*) to the scoped namespace (__thv_registry_*).
The factory and API login/logout handlers were still using the bare
provider, so token lookups failed after migration and returned 401.

Switch factory.go and the API registry auth handler to use
CreateProvider with WithScope(ScopeRegistry). ScopedProvider.GetSecret
falls back to bare keys during the migration window, and all new
reads/writes go through the scoped namespace consistently.

Also fix EncryptedManager.DeleteSecret to return ErrSecretNotFound
(matching GetSecret) so callers relying on IsNotFoundError handle
delete-not-found correctly.

Fix #4892
@github-actions github-actions bot added the size/XS Extra small PR: < 100 lines changed label Apr 16, 2026
@github-actions github-actions bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Apr 16, 2026
rdimitrov
rdimitrov previously approved these changes Apr 16, 2026
amirejaz
amirejaz previously approved these changes Apr 16, 2026
@eleftherias eleftherias dismissed stale reviews from amirejaz and rdimitrov via 354118d April 16, 2026 12:03
@github-actions github-actions bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Apr 16, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 16, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.21%. Comparing base (d5addcd) to head (354118d).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pkg/api/v1/registry.go 0.00% 1 Missing ⚠️
pkg/registry/factory.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4893      +/-   ##
==========================================
+ Coverage   69.09%   69.21%   +0.11%     
==========================================
  Files         531      531              
  Lines       55196    55159      -37     
==========================================
+ Hits        38140    38179      +39     
+ Misses      14131    14061      -70     
+ Partials     2925     2919       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eleftherias eleftherias merged commit d944774 into main Apr 16, 2026
68 of 69 checks passed
@eleftherias eleftherias deleted the fix-registry-list branch April 16, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Registry list prompts browser OAuth flow after login

3 participants