fix: fix buildkit www-authenticate challenges with depot registry#439
Merged
WitoDelnat merged 2 commits intomainfrom Feb 25, 2026
Merged
fix: fix buildkit www-authenticate challenges with depot registry#439WitoDelnat merged 2 commits intomainfrom
WitoDelnat merged 2 commits intomainfrom
Conversation
f1bd206 to
7657083
Compare
This comment has been minimized.
This comment has been minimized.
Contributor
Author
| }, nil | ||
| } | ||
| return nil, nil | ||
| } |
There was a problem hiding this comment.
Credential lookup logic duplicated across two methods
Low Severity
The new findCredentials method duplicates the base64-decoding and colon-splitting credential lookup logic already present in the existing Credentials method on AuthProvider. If the credential format or validation ever changes, both places need to be updated in sync. Credentials could be refactored to call findCredentials internally and convert the result, eliminating the duplicated parsing logic.
Additional Locations (1)
|
Bugbot Autofix prepared fixes for 1 of the 1 bugs found in the latest run.
Or push these changes by commenting: Preview (6d6175bdae)diff --git a/pkg/registry/auth.go b/pkg/registry/auth.go
--- a/pkg/registry/auth.go
+++ b/pkg/registry/auth.go
@@ -60,24 +60,16 @@
}
func (a *AuthProvider) Credentials(ctx context.Context, req *auth.CredentialsRequest) (*auth.CredentialsResponse, error) {
- for _, c := range a.credentials {
- if c.Host == req.Host {
- decodedAuth, err := base64.StdEncoding.DecodeString(c.Token)
- if err != nil {
- return nil, err
- }
-
- usernamePassword := strings.SplitN(string(decodedAuth), ":", 2)
- if len(usernamePassword) != 2 {
- return nil, fmt.Errorf("invalid auth string")
- }
-
- return &auth.CredentialsResponse{
- Username: usernamePassword[0],
- Secret: usernamePassword[1],
- }, nil
- }
+ creds, err := a.findCredentials(req.Host)
+ if err != nil {
+ return nil, err
}
+ if creds != nil {
+ return &auth.CredentialsResponse{
+ Username: creds.Username,
+ Secret: creds.Password,
+ }, nil
+ }
return a.inner.Credentials(ctx, req)
} |
jacobwgillespie
approved these changes
Feb 25, 2026
…ssing ACR status code - Extract shared fetchTokenWithFallback helper function to eliminate code duplication between AuthProvider.FetchToken and DepotAuthProvider.FetchToken - Update findCredentials to return error instead of silently skipping malformed credentials, making error handling consistent with Credentials method - Update OAuth POST fallback to handle all ErrUnexpectedStatus codes, not just 405/404/401, which fixes ACR compatibility (ACR returns 400) Applied via @cursor push command
0631ebd to
337bfa3
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.



There is a correct implementation when using the legacy moby driver, but with Buildkit it was incorrectly handled in the now patched files. Previously no such custom auth logic existed. This bug was never caught because for the legacy registry, our proxy never returns a www-authenticate challenge since it hi-jacks authentication itself and mints a token before redirecting to upstream registry.