Merge pull request #2748 from canton7/feature/multiple-api-keys

Support multiple API keys (command-line and config) (fixed #2747)
This commit is contained in:
Audrius Butkevicius
2016-02-01 09:20:51 +00:00
5 changed files with 18 additions and 10 deletions

View File

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