Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HTTP credentials passing #11538

Merged
merged 27 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b162d88
Add unit tests for multiAuthHeader
mtrmac Sep 11, 2021
ff00392
Add unit tests for singleAuthHeader
mtrmac Sep 11, 2021
5a5aa60
Improve TestAuthConfigsToAuthFile
mtrmac Sep 11, 2021
ad7e5e3
Add tests for auth.Header
mtrmac Sep 11, 2021
d29a4a6
Add TestHeaderGetCredentialsRoundtrip
mtrmac Sep 11, 2021
1b6bf97
Rename normalize and a few variables
mtrmac Sep 11, 2021
491951d
Fix normalizeAuthFileKey to use the correct semantics
mtrmac Sep 11, 2021
2aeb690
Don't return a header name from auth.GetCredentials
mtrmac Sep 11, 2021
7674f2f
Simplify the interface of parseSingleAuthHeader
mtrmac Sep 11, 2021
6f1a26b
Simplify parseSingleAuthHeader
mtrmac Sep 11, 2021
1ecc6ba
Pass a header value directly to parseSingleAuthHeader and parseMultiA…
mtrmac Sep 11, 2021
2946e83
Beautify GetCredentials.has a bit
mtrmac Sep 11, 2021
1589d70
Use Header.Values in GetCredentials.has
mtrmac Sep 11, 2021
da86a23
Only look up HTTP header values once in GetCredentials
mtrmac Sep 11, 2021
9d56ebb
Consolidate the error handling path in GetCredentials
mtrmac Sep 11, 2021
29f4088
Move the auth file creation to GetCredentials
mtrmac Sep 11, 2021
8155fb5
Turn headerConfig into MakeXRegistryConfigHeader
mtrmac Sep 11, 2021
d073b12
Call MakeXRegistryConfigHeader instead of Header(..., XRegistryConfig…
mtrmac Sep 11, 2021
78dd797
Turn headerAuth into MakeXRegistryAuthHeader
mtrmac Sep 11, 2021
3725a34
Call MakeXRegistryAuthHeader instead of Header(..., XRegistryAuthHeader)
mtrmac Sep 11, 2021
fe1230e
Remove pkg/auth.Header
mtrmac Oct 21, 2021
0e29b89
Consolidate creation of SystemContext with auth.json into a helper
mtrmac Oct 21, 2021
935dcbb
Remove no-longer-useful name variables
mtrmac Oct 21, 2021
f9be326
Remove the authfile parameter of MakeXRegistryConfigHeader
mtrmac Oct 21, 2021
d79414c
Simplify the header decision in pkg/bindings/images.Build a bit
mtrmac Oct 21, 2021
3cfefa1
Remove the authfile parameter of MakeXRegistryAuthHeader
mtrmac Oct 21, 2021
5bbcfaf
Make XRegistryAuthHeader and XRegistryConfigHeader private
mtrmac Oct 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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