fix: fix scanner apikey type match error

Signed-off-by: chlins <chlins.zhang@gmail.com>
This commit is contained in:
chlins 2020-10-21 18:29:19 +08:00
parent 8af343f27a
commit 21b56d241a
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 // 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,
} }
} }

View File

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