Merge pull request #13330 from chlins/fix/scanner-apikey-authorization

fix: fix scanner apikey type match error
This commit is contained in:
Steven Zou 2020-11-23 17:06:35 +08:00 committed by GitHub
commit 35a0fc7afd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -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,
}
}

View File

@ -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)
}