mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-29 19:11:24 +01:00
fix: fix scanner apikey type match error
Signed-off-by: chlins <chlins.zhang@gmail.com>
This commit is contained in:
parent
8af343f27a
commit
21b56d241a
@ -37,9 +37,9 @@ func (aa *apiKeyAuthorizer) Authorize(req *http.Request) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewAPIKeyAuthorizer news a apiKeyAuthorizer
|
// NewAPIKeyAuthorizer news a apiKeyAuthorizer
|
||||||
func NewAPIKeyAuthorizer(accessCred string) Authorizer {
|
func NewAPIKeyAuthorizer(key, accessCred string) Authorizer {
|
||||||
return &apiKeyAuthorizer{
|
return &apiKeyAuthorizer{
|
||||||
typeID: APIKey,
|
typeID: key,
|
||||||
accessCred: accessCred,
|
accessCred: accessCred,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,9 @@ const (
|
|||||||
// Bearer ...
|
// Bearer ...
|
||||||
Bearer = "Bearer"
|
Bearer = "Bearer"
|
||||||
// APIKey ...
|
// APIKey ...
|
||||||
APIKey = "X-ScannerAdapter-API-Key"
|
APIKey = "APIKey"
|
||||||
|
// APIKeyScannerAdapter ...
|
||||||
|
APIKeyScannerAdapter = "X-ScannerAdapter-API-Key"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Authorizer defines operation for authorizing the requests
|
// Authorizer defines operation for authorizing the requests
|
||||||
@ -47,7 +49,7 @@ func GetAuthorizer(auth, cred string) (Authorizer, error) {
|
|||||||
case Bearer:
|
case Bearer:
|
||||||
return NewBearerAuth(cred), nil
|
return NewBearerAuth(cred), nil
|
||||||
case APIKey:
|
case APIKey:
|
||||||
return NewAPIKeyAuthorizer(cred), nil
|
return NewAPIKeyAuthorizer(APIKeyScannerAdapter, cred), nil
|
||||||
default:
|
default:
|
||||||
return nil, errors.Errorf("auth type %s is not supported", auth)
|
return nil, errors.Errorf("auth type %s is not supported", auth)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user