summaryrefslogtreecommitdiff
path: root/pkg/api/handlers
diff options
context:
space:
mode:
authortroyready <troy@troyready.com>2021-03-10 19:16:03 -0800
committertroyready <troy@troyready.com>2021-03-12 10:48:03 -0800
commit955aaccc55218cd0022a1180df4c15bb27674a8f (patch)
tree65f460555d3c010402fc8eafeda2748739dc18f1 /pkg/api/handlers
parent9251b6c8cfaa5db738212c467c79f8c3aceb5b7d (diff)
downloadpodman-955aaccc55218cd0022a1180df4c15bb27674a8f.tar.gz
podman-955aaccc55218cd0022a1180df4c15bb27674a8f.tar.bz2
podman-955aaccc55218cd0022a1180df4c15bb27674a8f.zip
fix use with localhost (testing)
Signed-off-by: troyready <troy@troyready.com>
Diffstat (limited to 'pkg/api/handlers')
-rw-r--r--pkg/api/handlers/compat/auth.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/pkg/api/handlers/compat/auth.go b/pkg/api/handlers/compat/auth.go
index e914301f4..2c152fbc2 100644
--- a/pkg/api/handlers/compat/auth.go
+++ b/pkg/api/handlers/compat/auth.go
@@ -16,6 +16,13 @@ import (
"github.com/pkg/errors"
)
+func stripAddressOfScheme(address string) string {
+ for _, s := range []string{"https", "http"} {
+ address = strings.TrimPrefix(address, s+"://")
+ }
+ return address
+}
+
func Auth(w http.ResponseWriter, r *http.Request) {
var authConfig docker.AuthConfig
err := json.NewDecoder(r.Body).Decode(&authConfig)
@@ -25,7 +32,7 @@ func Auth(w http.ResponseWriter, r *http.Request) {
}
skipTLS := types.NewOptionalBool(false)
- if strings.HasPrefix(authConfig.ServerAddress, "http://localhost/") || strings.HasPrefix(authConfig.ServerAddress, "http://localhost:") {
+ if strings.HasPrefix(authConfig.ServerAddress, "https://localhost/") || strings.HasPrefix(authConfig.ServerAddress, "https://localhost:") || strings.HasPrefix(authConfig.ServerAddress, "localhost:") {
// support for local testing
skipTLS = types.NewOptionalBool(true)
}
@@ -37,7 +44,8 @@ func Auth(w http.ResponseWriter, r *http.Request) {
DockerInsecureSkipTLSVerify: skipTLS,
SystemRegistriesConfPath: registries.SystemRegistriesConfPath(),
}
- if err := DockerClient.CheckAuth(context.Background(), &sysCtx, authConfig.Username, authConfig.Password, authConfig.ServerAddress); err == nil {
+ registry := stripAddressOfScheme(authConfig.ServerAddress)
+ if err := DockerClient.CheckAuth(context.Background(), &sysCtx, authConfig.Username, authConfig.Password, registry); err == nil {
utils.WriteResponse(w, http.StatusOK, entities.AuthReport{
IdentityToken: "",
Status: "Login Succeeded",