added hmac validation to http based api

This commit is contained in:
2021-03-01 07:26:27 -09:00
parent 5c50f4ac95
commit 5571401103
5 changed files with 114 additions and 16 deletions

View File

@ -14,7 +14,7 @@ type Config struct {
DebugLevel int
Listen string
Path string
APIKey string
APIKey []byte
APIKeyFile string
}
@ -77,12 +77,12 @@ func ReadConfig(fn string, debuglvl int) (*Config, error) {
return nil, err
}
if cfg.APIKey == "" {
if len(cfg.APIKey) == 0 {
b, err := os.ReadFile(cfg.APIKeyFile)
if err != nil {
return nil, err
}
cfg.APIKey = string(b)
cfg.APIKey = b
}
return cfg, nil

View File

@ -71,7 +71,7 @@ func (p *parser) parse() error {
case "listen":
p.config.Listen = value
case "api.key":
p.config.APIKey = value
p.config.APIKey = []byte(value)
case "api.keyfile":
p.config.APIKeyFile = value
default: