Skip to content

Commit 7dc5b69

Browse files
Kevin Lamontagnejehiah
Kevin Lamontagne
authored andcommitted
secrets as environment variables. closes bitly#5
1 parent e300266 commit 7dc5b69

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

3435
func 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

0 commit comments

Comments
 (0)