Support multiple API keys (command-line and config) (fixes #2747)
This commit is contained in:
@@ -76,9 +76,17 @@ func (c GUIConfiguration) URL() string {
|
||||
return u.String()
|
||||
}
|
||||
|
||||
func (c GUIConfiguration) APIKey() string {
|
||||
if override := os.Getenv("STGUIAPIKEY"); override != "" {
|
||||
return override
|
||||
// Returns whether the given API key is valid, including both the value in config
|
||||
// and any overrides
|
||||
func (c GUIConfiguration) IsValidAPIKey(apiKey string) bool {
|
||||
switch apiKey {
|
||||
case "":
|
||||
return false
|
||||
|
||||
case c.RawAPIKey, os.Getenv("STGUIAPIKEY"):
|
||||
return true
|
||||
|
||||
default:
|
||||
return false
|
||||
}
|
||||
return c.RawAPIKey
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user