From 7dc5b691e7ab5942e9d674a43dd91295d82b258c Mon Sep 17 00:00:00 2001 From: Kevin Lamontagne Date: Tue, 30 Jul 2013 17:31:59 -0400 Subject: [PATCH] secrets as environment variables. closes #5 --- README.md | 2 ++ main.go | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/README.md b/README.md index 0e2caa9..a6f8b5c 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,9 @@ The command line to run `google_auth_proxy` would look like this: --client-secret=... ``` +## Environment variables +The environment variables `google_auth_client_id`, `google_auth_secret` and `google_auth_cookie_secret` can be used in place of the corresponding command-line arguments. ## Endpoint Documentation diff --git a/main.go b/main.go index 5d6cf67..7cf5777 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "net" + "os" "net/http" "net/url" "strings" @@ -32,8 +33,20 @@ func init() { } func main() { + flag.Parse() + // Try to use env for secrets if no flag is set + if *clientID == "" { + *clientID = os.Getenv("google_auth_client_id") + } + if *clientSecret == "" { + *clientSecret = os.Getenv("google_auth_secret") + } + if *cookieSecret == "" { + *cookieSecret = os.Getenv("google_auth_cookie_secret") + } + if *showVersion { fmt.Printf("google_auth_proxy v%s\n", VERSION) return