Revert "Migrate npm handler to OIDCRegistry"#94
Merged
Conversation
This reverts commit f75785f.
robaiken
approved these changes
Apr 7, 2026
There was a problem hiding this comment.
Pull request overview
Reverts the prior migration of the NPM registry handler to OIDCRegistry, returning NPM OIDC handling to a simpler host-keyed credential map approach to help investigate changed OIDC audience behavior.
Changes:
- Replaced NPM’s
OIDCRegistryusage with amap[host]*oidc.OIDCCredentialand inline token injection logic. - Updated OIDC handling tests to expect host-only registration log lines for NPM.
- Removed the test covering multiple NPM OIDC credentials on the same host with different URL paths.
Show a summary per file
| File | Description |
|---|---|
| internal/handlers/npm_registry.go | Reverts NPM OIDC auth flow from OIDCRegistry back to a host-keyed credential map with inline token/header handling. |
| internal/handlers/oidc_handling_test.go | Adjusts NPM OIDC registration log expectations and removes the same-host/different-paths NPM OIDC test. |
Copilot's findings
Comments suppressed due to low confidence (2)
internal/handlers/npm_registry.go:92
- OIDC credentials are stored keyed by
host, butHandleRequestlooks them up withreqHostdirectly. Because this is a case-sensitive map lookup, requests whose URL hostname differs in case (or other normalizable forms) from the config host will miss OIDC auth. Normalize the key consistently (e.g., lower-case/IDNA) on both insert and lookup, or usehelpers.CheckHost/AreHostnamesEqual-based matching instead of direct indexing.
// Try OIDC credentials first
h.mutex.RLock()
oidcCred, hasOIDC := h.oidcCredentials[reqHost]
h.mutex.RUnlock()
internal/handlers/npm_registry.go:105
- This OIDC auth block duplicates logic that already exists in
oidc.TryAuthOIDCRequestWithPrefix(including Cloudsmith header selection and consistent error logging). Reusing the shared helper would reduce drift across handlers and avoid needing to special-case providers by string comparison here.
if hasOIDC {
token, err := oidc.GetOrRefreshOIDCToken(oidcCred, req.Context())
if err != nil {
logging.RequestLogf(ctx, "* failed to get token via OIDC for %s: %v", reqHost, err)
// Fall through to try static credentials
} else {
if oidcCred.Provider() == "cloudsmith" {
logging.RequestLogf(ctx, "* authenticating npm registry request with OIDC API key (host: %s)", reqHost)
req.Header.Set("X-Api-Key", token)
} else {
logging.RequestLogf(ctx, "* authenticating npm registry request with OIDC token (host: %s)", reqHost)
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
}
- Files reviewed: 2/2 changed files
- Comments generated: 2
kbukum1
added a commit
that referenced
this pull request
Apr 7, 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.
We are reverting the change because the OIDC audience behaviour seems to changed. We need to test in original to find out the cause.
Reverts #91