From 118b06b15e5092b9ae484be7af791ca151b36e42 Mon Sep 17 00:00:00 2001 From: Dylan Murray Date: Wed, 2 May 2018 10:21:49 -0400 Subject: [PATCH 1/3] Bug 1558862 - Update openshift registry to not require realm auth challenges --- registries/adapters/openshift_adapter.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/registries/adapters/openshift_adapter.go b/registries/adapters/openshift_adapter.go index b4652eb..62b8535 100644 --- a/registries/adapters/openshift_adapter.go +++ b/registries/adapters/openshift_adapter.go @@ -101,11 +101,11 @@ func (r OpenShiftAdapter) getOpenShiftAuthToken() (string, error) { if strings.Index(authChallenge, "realm=\"") == -1 { return "", errors.New("failed to find realm in www-authenticate header") } + authOptions := "" if strings.Index(authChallenge, ",") == -1 { - return "", errors.New("failed to find realm options in www-authenticate header") + authOptions := strings.Split(authChallenge, ",")[1] } authRealm := strings.Split(strings.Split(authChallenge, "realm=\"")[1], "\"")[0] - authOptions := strings.Split(authChallenge, ",")[1] authURL := fmt.Sprintf("%v?%v", authRealm, authOptions) // Replace any quotes that exist in header from authOptions authURL = strings.Replace(authURL, "\"", "", -1) From 99471fd7b08688cc33a1989a3671f21f5b08024c Mon Sep 17 00:00:00 2001 From: Dylan Murray Date: Wed, 2 May 2018 10:22:46 -0400 Subject: [PATCH 2/3] fix conditional --- registries/adapters/openshift_adapter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registries/adapters/openshift_adapter.go b/registries/adapters/openshift_adapter.go index 62b8535..07b199b 100644 --- a/registries/adapters/openshift_adapter.go +++ b/registries/adapters/openshift_adapter.go @@ -102,7 +102,7 @@ func (r OpenShiftAdapter) getOpenShiftAuthToken() (string, error) { return "", errors.New("failed to find realm in www-authenticate header") } authOptions := "" - if strings.Index(authChallenge, ",") == -1 { + if strings.Index(authChallenge, ",") != -1 { authOptions := strings.Split(authChallenge, ",")[1] } authRealm := strings.Split(strings.Split(authChallenge, "realm=\"")[1], "\"")[0] From bd651d3b2d92265a6e3ce8353d1d5929ca10ebbd Mon Sep 17 00:00:00 2001 From: Dylan Murray Date: Wed, 2 May 2018 11:30:48 -0400 Subject: [PATCH 3/3] fix dumb error --- registries/adapters/openshift_adapter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registries/adapters/openshift_adapter.go b/registries/adapters/openshift_adapter.go index 07b199b..739c123 100644 --- a/registries/adapters/openshift_adapter.go +++ b/registries/adapters/openshift_adapter.go @@ -103,7 +103,7 @@ func (r OpenShiftAdapter) getOpenShiftAuthToken() (string, error) { } authOptions := "" if strings.Index(authChallenge, ",") != -1 { - authOptions := strings.Split(authChallenge, ",")[1] + authOptions = strings.Split(authChallenge, ",")[1] } authRealm := strings.Split(strings.Split(authChallenge, "realm=\"")[1], "\"")[0] authURL := fmt.Sprintf("%v?%v", authRealm, authOptions)