built-in ClientID / ClientSecret take precedence

This commit is contained in:
AJ ONeal 2020-07-17 08:32:23 +00:00
parent 58dc369ce1
commit f362427e7b
1 changed files with 20 additions and 0 deletions

View File

@ -157,15 +157,35 @@ func main() {
// Baked-in takes precedence
if 0 == len(ClientID) {
ClientID = *appID
} else if 0 != len(*appID) {
if ClientID != *appID {
fmt.Fprintf(os.Stderr, "invalid --app-id\n")
os.Exit(1)
}
}
if 0 == len(ClientID) {
ClientID = os.Getenv("APP_ID")
} else if 0 != len(os.Getenv("APP_ID")) {
if ClientID != os.Getenv("APP_ID") {
fmt.Fprintf(os.Stderr, "invalid APP_ID\n")
os.Exit(1)
}
}
if 0 == len(ClientSecret) {
ClientSecret = *secret
} else if 0 != len(*secret) {
if ClientSecret != *secret {
fmt.Fprintf(os.Stderr, "invalid --secret\n")
os.Exit(1)
}
}
if 0 == len(ClientSecret) {
ClientSecret = os.Getenv("SECRET")
} else if 0 != len(os.Getenv("SECRET")) {
if ClientSecret != os.Getenv("SECRET") {
fmt.Fprintf(os.Stderr, "invalid SECRET\n")
os.Exit(1)
}
}
ppid, err := machineid.ProtectedID(fmt.Sprintf("%s|%s", ClientID, ClientSecret))
if nil != err {