Commit b3012ec0 authored by chlins's avatar chlins Committed by Ziming
Browse files

fix(replication): fix quay adapter authorization


Signed-off-by: default avatarchlins <chlins.zhang@gmail.com>
parent 7970f77c
......@@ -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"
};
......
......@@ -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 {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment