From b3012ec08dbce99297dbef66ccdf4cb2b10ebcd0 Mon Sep 17 00:00:00 2001 From: chlins Date: Tue, 11 Aug 2020 13:43:04 +0800 Subject: [PATCH] fix(replication): fix quay adapter authorization Signed-off-by: chlins --- .../src/lib/services/endpoint.service.ts | 4 ++-- src/replication/adapter/quay/adapter.go | 19 ++++--------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/portal/src/lib/services/endpoint.service.ts b/src/portal/src/lib/services/endpoint.service.ts index b9a8f4816..3d23356e5 100644 --- a/src/portal/src/lib/services/endpoint.service.ts +++ b/src/portal/src/lib/services/endpoint.service.ts @@ -23,8 +23,8 @@ const ADAPTERS_MAP = { "harbor": "Harbor", "helm-hub": "Helm Hub", "huawei-SWR": "Huawei SWR", - "jfrog-artifactory": "jFrog Artifactory", - "quay-io": "Quay.io" + "jfrog-artifactory": "JFrog Artifactory", + "quay": "Quay" }; diff --git a/src/replication/adapter/quay/adapter.go b/src/replication/adapter/quay/adapter.go index 5cab569ea..d07b1b614 100644 --- a/src/replication/adapter/quay/adapter.go +++ b/src/replication/adapter/quay/adapter.go @@ -10,11 +10,10 @@ import ( "net/http" "strings" - "github.com/goharbor/harbor/src/pkg/registry/auth/basic" - common_http "github.com/goharbor/harbor/src/common/http" "github.com/goharbor/harbor/src/common/http/modifier" "github.com/goharbor/harbor/src/lib/log" + "github.com/goharbor/harbor/src/pkg/registry/auth" adp "github.com/goharbor/harbor/src/replication/adapter" "github.com/goharbor/harbor/src/replication/adapter/native" "github.com/goharbor/harbor/src/replication/model" @@ -47,7 +46,7 @@ func newAdapter(registry *model.Registry) (*adapter, error) { var ( autoCreateNs bool - basicAuthorizer, apiKeyAuthorizer modifier.Modifier + tokenAuthorizer, apiKeyAuthorizer modifier.Modifier ) if registry.Credential != nil && len(registry.Credential.AccessSecret) != 0 { @@ -56,14 +55,14 @@ func newAdapter(registry *model.Registry) (*adapter, error) { if err != nil { return nil, err } - basicAuthorizer = basic.NewAuthorizer(jsonCred.AccountName, jsonCred.DockerCliPassword) + tokenAuthorizer = auth.NewAuthorizer(jsonCred.AccountName, jsonCred.DockerCliPassword, registry.Insecure) if len(jsonCred.OAuth2Token) != 0 { autoCreateNs = true apiKeyAuthorizer = NewAPIKeyAuthorizer("Authorization", fmt.Sprintf("Bearer %s", jsonCred.OAuth2Token), APIKeyInHeader) } } - nativeRegistryAdapter := native.NewAdapterWithAuthorizer(registry, basicAuthorizer) + nativeRegistryAdapter := native.NewAdapterWithAuthorizer(registry, tokenAuthorizer) if apiKeyAuthorizer != nil { modifiers = append(modifiers, apiKeyAuthorizer) @@ -128,16 +127,6 @@ func (a *adapter) Info() (*model.RegistryInfo, error) { }, nil } -// HealthCheck checks health status of a registry -func (a *adapter) HealthCheck() (model.HealthStatus, error) { - err := a.PingSimple() - if err != nil { - return model.Unhealthy, nil - } - - return model.Healthy, nil -} - // PrepareForPush does the prepare work that needed for pushing/uploading the resource // eg: create the namespace or repository func (a *adapter) PrepareForPush(resources []*model.Resource) error {