Open
Conversation
12 tasks
There was a problem hiding this comment.
Pull request overview
Refactors the Helm registry handler to use the shared oidc.OIDCRegistry (introduced in #78) instead of maintaining its own OIDC credential map + mutex, to align with the collision-free OIDC credential storage approach.
Changes:
- Replace per-handler OIDC credential storage (
map+sync.RWMutex) with*oidc.OIDCRegistry. - Register Helm OIDC credentials via
OIDCRegistry.Register(...)during handler construction. - Authenticate requests via
OIDCRegistry.TryAuth(...)instead ofTryAuthOIDCRequestWithPrefix(...).
74c2bcc to
cb1d91e
Compare
cb1d91e to
8a474ff
Compare
Comment on lines
+43
to
+44
| // OIDC credentials are not used as static credentials. | ||
| if oidcCred, _, _ := handler.oidcRegistry.Register(cred, []string{"registry"}, "helm registry"); oidcCred != nil { |
There was a problem hiding this comment.
OIDCRegistry.Register returns (cred, key, registered) but this code only checks oidcCred != nil and ignores whether the credential was actually registered (e.g., missing/invalid registry/host). That can silently drop an OIDC-configured credential with no warning and make misconfigurations harder to diagnose. Consider switching the condition to use the registered boolean (and optionally log when oidcCred != nil but registered == false).
Suggested change
| // OIDC credentials are not used as static credentials. | |
| if oidcCred, _, _ := handler.oidcRegistry.Register(cred, []string{"registry"}, "helm registry"); oidcCred != nil { | |
| // OIDC credentials are not used as static credentials once successfully registered. | |
| if _, _, registered := handler.oidcRegistry.Register(cred, []string{"registry"}, "helm registry"); registered { |
Replace manual OIDC credential map and mutex with the shared OIDCRegistry type. Helm already used the raw registry value as the key, so this is a pure structural refactor with no behavior change.
8a474ff to
978b092
Compare
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.
What
Migrate the Helm registry handler from manual OIDC credential map + mutex to the shared
OIDCRegistrytype introduced in #78.Why
Part of the phased migration to fix OIDC credential collisions when multiple registries share a host (#87).
Helm already stored the raw
registryvalue as the OIDC key, so this is a pure structural refactor with no behavior change. Single-file diff, no test changes.Behavior changes
Credential selection is now deterministic. The old code iterated over a Go map (
map[string]*OIDCCredential), so with multiple OIDC credentials on the same host, which one matched was nondeterministic.OIDCRegistry.TryAuthuses longest path-prefix matching, ensuring the most specific credential always wins. This is the core fix for OIDC credential collision when multiple registries share a host #87.Host matching uses
strings.ToLowerinstead of IDNA normalization. The oldTryAuthOIDCRequestWithPrefixusedhelpers.AreHostnamesEqual(IDNAToASCII), whileOIDCRegistry.TryAuthuses lowercase comparison. This is acceptable because all real OIDC registries (Azure DevOps, JFrog, AWS CodeArtifact, Cloudsmith) use ASCII hostnames — no package registry uses internationalized domain names.