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 committed 2016-02-01 09:20:51 +00:00
commit 60ca7784ba
5 files changed
+18 -10

No files matched your search

+12 -4
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
}