git.iko.soy/typeable/oauth2-proxy
on master help sign in
secrets as environment variables. closes #5
commit7dc5b691e7ab5942e9d674a43dd91295d82b258c authorKevin Lamontagne <kevin@demarque.com> dateTue 30 Jul 2013, 17:31 (13 years ago) parente300266
2 files changed+15
README.md+2 main.go+13
README.md+2
@@ -96,7 +96,9 @@ The command line to run `google_auth_proxy` would look like this:
9696 --client-secret=...
9797```
9898
99+## Environment variables
99100
101+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.
100102
101103## Endpoint Documentation
102104
main.go+13
@@ -5,6 +5,7 @@ import (
55 "fmt"
66 "log"
77 "net"
8+ "os"
89 "net/http"
910 "net/url"
1011 "strings"
@@ -32,8 +33,20 @@ func init() {
3233}
3334
3435func main() {
36+
3537 flag.Parse()
3638
39+ // Try to use env for secrets if no flag is set
40+ if *clientID == "" {
41+ *clientID = os.Getenv("google_auth_client_id")
42+ }
43+ if *clientSecret == "" {
44+ *clientSecret = os.Getenv("google_auth_secret")
45+ }
46+ if *cookieSecret == "" {
47+ *cookieSecret = os.Getenv("google_auth_cookie_secret")
48+ }
49+
3750 if *showVersion {
3851 fmt.Printf("google_auth_proxy v%s\n", VERSION)
3952 return