Open
Conversation
This was referenced Apr 3, 2026
There was a problem hiding this comment.
Pull request overview
Migrates the NuGet feed handler’s OIDC handling to the shared oidc.OIDCRegistry, aligning NuGet with the registry-based, path-prefix OIDC matching model introduced in #78 to avoid credential collisions when multiple feeds share a host.
Changes:
- Replaced the NuGet handler’s per-handler OIDC map + RWMutex with
*oidc.OIDCRegistry, and switched request-time auth tooidcRegistry.TryAuth(). - Added registration of NuGet HTTP-discovered resource URLs via
oidcRegistry.RegisterURL(...). - Updated OIDC log-line expectations in
oidc_handling_test.goto match the new registration log format.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/handlers/nuget_feed.go | Uses OIDCRegistry for OIDC credential storage/matching and registers discovered NuGet resource URLs via RegisterURL. |
| internal/handlers/oidc_handling_test.go | Updates expected log lines for NuGet OIDC resource registration output. |
Comments suppressed due to low confidence (1)
internal/handlers/nuget_feed.go:92
- The log line on
io.ReadAllfailure drops the underlying error and the URL being fetched, which makes diagnosing feed discovery issues harder. Include botherrand thekey/URL in the message (and consider logging response status when relevant).
body, err := io.ReadAll(rawRsp.Body)
if err != nil {
logging.RequestLogf(nil, "error reading http response body")
continue
cd8f757 to
cc65780
Compare
cc65780 to
06698f6
Compare
06698f6 to
77ba13e
Compare
77ba13e to
c8bf1a1
Compare
c8bf1a1 to
65234e2
Compare
Replace manual OIDC credential map and mutex with the shared OIDCRegistry type. Nuget uses Register() for the primary feed URL and RegisterURL() for HTTP-discovered resource URLs. The old code stored OIDC credentials by url-with-host-fallback. OIDCRegistry preserves the full URL with path-prefix matching, fixing potential collisions when multiple nuget feeds share a host. Test log lines updated: RegisterURL uses consistent log format without the leading indent that the old code used.
65234e2 to
a63f4fd
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 NuGet feed 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).
NuGet previously stored OIDC credentials by url-with-host-fallback.
OIDCRegistrypreserves the full URL with path-prefix matching, fixing potential collisions when multiple NuGet feeds share a host.Key changes
oidcCredentials map[string]*oidc.OIDCCredential+sync.RWMutexwith*oidc.OIDCRegistryRegister(cred, ["url"], "nuget feed")RegisterURL(discoveredURL, credential, "nuget resource")— this is the only handler that usesRegisterURLoidcRegistry.TryAuth()instead ofTryAuthOIDCRequestWithPrefix()RegisterURLuses consistent format without the leading indent the old code usedBehavior 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.OIDC auth restricted to HTTPS only. Previously
TryAuthOIDCRequestWithPrefixhad no scheme guard, so OIDC tokens could be sent over plaintext HTTP. Now gated withreq.URL.Scheme == "https"to prevent credential leakage. Static credentials continue to work over both HTTP and HTTPS (existing nuget behavior).OIDC discovery guarded with
url != "". Host-only credentials (from CLI) are still registered for request-time matching, but feed index discovery is skipped when the URL field is empty since bare hostnames are not valid request URLs.Response body leak fix. Both the OIDC and static credential discovery blocks now use a closure with
defer rawRsp.Body.Close(), fixing a pre-existing bug where the body was leaked onio.ReadAllerror or early-return status code paths.