fix(upstream): apply authentication through shared transport#198
Open
andrew wants to merge 2 commits into
Open
fix(upstream): apply authentication through shared transport#198andrew wants to merge 2 commits into
andrew wants to merge 2 commits into
Conversation
3e14007 to
f8f475a
Compare
There was a problem hiding this comment.
Pull request overview
This PR centralizes upstream authentication by introducing an authentication-aware HTTP transport that is shared across both metadata and artifact-fetch paths, and adds OCI Bearer-challenge discovery + scoped token caching to avoid hard-coded token endpoints and prevent credential leakage to lookalike hosts.
Changes:
- Wire a shared SSRF-safe, auth-aware transport into both the proxy metadata HTTP client and the artifact fetcher.
- Add
internal/httpclient.Transportto apply configured auth headers and handle OCIWWW-Authenticate: Bearer …challenges with token caching. - Tighten
upstream.authmatching to compare parsed URL components (scheme/host/effective port/path boundary), and update docs/examples accordingly.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/server/server.go | Builds shared SSRF-safe client + auth transport; uses it for metadata and artifacts consistently. |
| internal/httpclient/transport.go | New auth-aware RoundTripper with OCI Bearer challenge discovery and token caching. |
| internal/httpclient/transport_test.go | Adds unit tests for challenge following, token caching, and configured/explicit auth behavior. |
| internal/config/config.go | Changes upstream auth matching from raw prefix to parsed URL component + path-boundary matching. |
| internal/config/config_test.go | Adds coverage for host/scheme/port/path-boundary matching behavior. |
| docs/configuration.md | Updates auth documentation to reflect URL-scope matching and OCI challenge-based auth. |
| docs/architecture.md | Notes shared auth transport + OCI token discovery/caching in system architecture. |
| config.example.yaml | Updates comments to reflect the new URL-scope auth matching rules. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The PR description says:
but this is still in container.go: |
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.
Summary
Why
Several Proxy request paths use the raw HTTP client instead of Fetcher, so
upstream.authwas not applied consistently. This centralizes authentication below both paths and provides challenge-based OCI authentication without hard-coded Docker Hub token endpoints.This is PR 1 of 2. The OCI offline-cache fix is stacked on this branch.
Validation
go test ./... -count=1go test -race ./... -count=1go tool golangci-lint run ./...