storj/pointerdb/auth/process_api_key.go
JT Olio 45a3c2e974
pkg/provider: with pkg/provider merged, make a single heavy client binary, gateway binary, and deprecate old services (#165)
* 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
2018-07-26 08:21:35 -06:00

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