45a3c2e974
* pkg/provider: with pkg/provider merged, make a single heavy client binary and deprecate old services * add setup to gw binary too * captplanet: output what addresses everything is listening on * revert peertls/io_util changes * define config flag across all commands * use trimsuffix
26 lines
484 B
Go
26 lines
484 B
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package auth
|
|
|
|
import (
|
|
"crypto/subtle"
|
|
"flag"
|
|
)
|
|
|
|
var (
|
|
apiKey = flag.String("pointer-db.auth.api-key", "", "api key")
|
|
)
|
|
|
|
// ValidateAPIKey : validates the X-API-Key header to an env/flag input
|
|
func ValidateAPIKey(header string) bool {
|
|
var expected = []byte(*apiKey)
|
|
var actual = []byte(header)
|
|
|
|
if len(expected) <= 0 {
|
|
return false
|
|
}
|
|
|
|
return 1 == subtle.ConstantTimeCompare(expected, actual)
|
|
}
|