Skip to content

Commit

Permalink
Merge pull request #11538 from mtrmac/http-credentials
Browse files Browse the repository at this point in the history
Fix HTTP credentials passing
  • Loading branch information
openshift-merge-robot authored Jan 6, 2022
2 parents c0b3df8 + 5bbcfaf commit 2fd6c2e
Show file tree
Hide file tree
Showing 14 changed files with 503 additions and 155 deletions.
4 changes: 2 additions & 2 deletions pkg/api/handlers/compat/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ func CreateImageFromImage(w http.ResponseWriter, r *http.Request) {
return
}

authConf, authfile, key, err := auth.GetCredentials(r)
authConf, authfile, err := auth.GetCredentials(r)
if err != nil {
utils.Error(w, "failed to retrieve repository credentials", http.StatusBadRequest, errors.Wrapf(err, "failed to parse %q header for %s", key, r.URL.String()))
utils.Error(w, "failed to retrieve repository credentials", http.StatusBadRequest, err)
return
}
defer auth.RemoveAuthfile(authfile)
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/handlers/compat/images_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,10 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
}
}

creds, authfile, key, err := auth.GetCredentials(r)
creds, authfile, err := auth.GetCredentials(r)
if err != nil {
// Credential value(s) not returned as their value is not human readable
utils.BadRequest(w, key.String(), "n/a", err)
utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest, err)
return
}
defer auth.RemoveAuthfile(authfile)
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/handlers/compat/images_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
return
}

authconf, authfile, key, err := auth.GetCredentials(r)
authconf, authfile, err := auth.GetCredentials(r)
if err != nil {
utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse %q header for %s", key, r.URL.String()))
utils.Error(w, "Something went wrong.", http.StatusBadRequest, err)
return
}
defer auth.RemoveAuthfile(authfile)
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/handlers/compat/images_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ func SearchImages(w http.ResponseWriter, r *http.Request) {
return
}

_, authfile, key, err := auth.GetCredentials(r)
_, authfile, err := auth.GetCredentials(r)
if err != nil {
utils.Error(w, "failed to retrieve repository credentials", http.StatusBadRequest, errors.Wrapf(err, "failed to parse %q header for %s", key, r.URL.String()))
utils.Error(w, "failed to retrieve repository credentials", http.StatusBadRequest, err)
return
}
defer auth.RemoveAuthfile(authfile)
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/handlers/libpod/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,9 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
return
}

authconf, authfile, key, err := auth.GetCredentials(r)
authconf, authfile, err := auth.GetCredentials(r)
if err != nil {
utils.Error(w, "failed to retrieve repository credentials", http.StatusBadRequest, errors.Wrapf(err, "failed to parse %q header for %s", key, r.URL.String()))
utils.Error(w, "failed to retrieve repository credentials", http.StatusBadRequest, err)
return
}
defer auth.RemoveAuthfile(authfile)
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/handlers/libpod/images_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ func ImagesPull(w http.ResponseWriter, r *http.Request) {
}

// Do the auth dance.
authConf, authfile, key, err := auth.GetCredentials(r)
authConf, authfile, err := auth.GetCredentials(r)
if err != nil {
utils.Error(w, "failed to retrieve repository credentials", http.StatusBadRequest, errors.Wrapf(err, "failed to parse %q header for %s", key, r.URL.String()))
utils.Error(w, "failed to retrieve repository credentials", http.StatusBadRequest, err)
return
}
defer auth.RemoveAuthfile(authfile)
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/handlers/libpod/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ func ManifestPush(w http.ResponseWriter, r *http.Request) {
}

source := utils.GetName(r)
authconf, authfile, key, err := auth.GetCredentials(r)
authconf, authfile, err := auth.GetCredentials(r)
if err != nil {
utils.Error(w, "failed to retrieve repository credentials", http.StatusBadRequest, errors.Wrapf(err, "failed to parse %q header for %s", key, r.URL.String()))
utils.Error(w, "failed to retrieve repository credentials", http.StatusBadRequest, err)
return
}
defer auth.RemoveAuthfile(authfile)
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/handlers/libpod/play.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ func PlayKube(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error closing temporary file"))
return
}
authConf, authfile, key, err := auth.GetCredentials(r)
authConf, authfile, err := auth.GetCredentials(r)
if err != nil {
utils.Error(w, "failed to retrieve repository credentials", http.StatusBadRequest, errors.Wrapf(err, "failed to parse %q header for %s", key, r.URL.String()))
utils.Error(w, "failed to retrieve repository credentials", http.StatusBadRequest, err)
return
}
defer auth.RemoveAuthfile(authfile)
Expand Down
Loading

0 comments on commit 2fd6c2e

Please sign in to comment.