mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 20:26:13 +01:00
Merge pull request #13330 from chlins/fix/scanner-apikey-authorization
fix: fix scanner apikey type match error
This commit is contained in:
commit
35a0fc7afd
@ -37,9 +37,9 @@ func (aa *apiKeyAuthorizer) Authorize(req *http.Request) error {
|
||||
}
|
||||
|
||||
// NewAPIKeyAuthorizer news a apiKeyAuthorizer
|
||||
func NewAPIKeyAuthorizer(accessCred string) Authorizer {
|
||||
func NewAPIKeyAuthorizer(key, accessCred string) Authorizer {
|
||||
return &apiKeyAuthorizer{
|
||||
typeID: APIKey,
|
||||
typeID: key,
|
||||
accessCred: accessCred,
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,9 @@ const (
|
||||
// Bearer ...
|
||||
Bearer = "Bearer"
|
||||
// APIKey ...
|
||||
APIKey = "X-ScannerAdapter-API-Key"
|
||||
APIKey = "APIKey"
|
||||
// APIKeyScannerAdapter ...
|
||||
APIKeyScannerAdapter = "X-ScannerAdapter-API-Key"
|
||||
)
|
||||
|
||||
// Authorizer defines operation for authorizing the requests
|
||||
@ -47,7 +49,7 @@ func GetAuthorizer(auth, cred string) (Authorizer, error) {
|
||||
case Bearer:
|
||||
return NewBearerAuth(cred), nil
|
||||
case APIKey:
|
||||
return NewAPIKeyAuthorizer(cred), nil
|
||||
return NewAPIKeyAuthorizer(APIKeyScannerAdapter, cred), nil
|
||||
default:
|
||||
return nil, errors.Errorf("auth type %s is not supported", auth)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user