You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-12Lines changed: 21 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -42,28 +42,40 @@ intend to run `google_auth_proxy` on.
42
42
5. Take note of the **Client ID** and **Client Secret**
43
43
44
44
45
-
## Command Line Options
45
+
## Configuration
46
+
47
+
`google_auth_proxy` can be configured via [config file](#config-file), [command line options](#command-line-options) or [environment variables](#environment-variables).
48
+
49
+
### Config File
50
+
51
+
An example [google_auth_proxy.cfg](contrib/google_auth_proxy.cfg.example) config file is in the contrib directory. It can be used by specifying `-config=/etc/google_auth_proxy.cfg`
52
+
53
+
### Command Line Options
46
54
47
55
```
48
-
Usage of ./google_auth_proxy:
56
+
Usage of google_auth_proxy:
49
57
-authenticated-emails-file="": authenticate against emails via file (one per line)
50
58
-client-id="": the Google OAuth Client ID: ie: "123456.apps.googleusercontent.com"
51
59
-client-secret="": the OAuth Client Secret
52
-
-cookie-domain="": an optional cookie domain to force cookies to
53
-
-cookie-expire=168h: expire timeframe for cookie
60
+
-config="": path to config file
61
+
-cookie-domain="": an optional cookie domain to force cookies to (ie: .yourcompany.com)
62
+
-cookie-expire=168h0m0s: expire timeframe for cookie
54
63
-cookie-https-only=false: set HTTPS only cookie
55
64
-cookie-secret="": the seed string for secure cookies
56
-
-google-apps-domain=[]: authenticate against the given google apps domain (may be given multiple times)
65
+
-google-apps-domain=: authenticate against the given Google apps domain (may be given multiple times)
57
66
-htpasswd-file="": additionally authenticate against a htpasswd file. Entries must be created with "htpasswd -s" for SHA encryption
58
67
-http-address="127.0.0.1:4180": <addr>:<port> to listen on for HTTP clients
59
-
-pass-basic-auth=true: pass HTTP Basic Auth information to upstream
68
+
-pass-basic-auth=true: pass HTTP Basic Auth, X-Forwarded-User and X-Forwarded-Email information to upstream
60
69
-redirect-url="": the OAuth Redirect URL. ie: "https://internalapp.yourcompany.com/oauth2/callback"
61
-
-upstream=[]: the http url(s) of the upstream endpoint. If multiple, routing is based on path
70
+
-upstream=: the http url(s) of the upstream endpoint. If multiple, routing is based on path
62
71
-version=false: print version string
63
72
```
64
73
74
+
### Environment variables
65
75
66
-
## Example Configuration
76
+
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.
77
+
78
+
### Example Nginx Configuration
67
79
68
80
This example has a [Nginx](http://nginx.org/) SSL endpoint proxying to `google_auth_proxy` on port `4180`.
69
81
`google_auth_proxy` then authenticates requests for an upstream application running on port `8080`. The external
@@ -105,13 +117,10 @@ The command line to run `google_auth_proxy` would look like this:
105
117
--client-secret=...
106
118
```
107
119
108
-
## Environment variables
109
-
110
-
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.
111
120
112
121
## Endpoint Documentation
113
122
114
-
Google Auth Proxy responds directly to the following endpoints. All other endpoints will be authenticated.
123
+
Google Auth Proxy responds directly to the following endpoints. All other endpoints will be proxied upstream when authenticated.
115
124
116
125
* /ping - returns an 200 OK response
117
126
* /oauth2/sign_in - the login page, which also doubles as a sign out page (it clears cookies)
Copy file name to clipboardExpand all lines: main.go
+65-69Lines changed: 65 additions & 69 deletions
Original file line number
Diff line number
Diff line change
@@ -6,109 +6,105 @@ import (
6
6
"log"
7
7
"net"
8
8
"net/http"
9
-
"net/url"
10
9
"os"
11
10
"strings"
12
11
"time"
13
-
)
14
12
15
-
constVERSION="0.1.0"
16
-
17
-
var (
18
-
showVersion=flag.Bool("version", false, "print version string")
19
-
httpAddr=flag.String("http-address", "127.0.0.1:4180", "<addr>:<port> to listen on for HTTP clients")
20
-
redirectUrl=flag.String("redirect-url", "", "the OAuth Redirect URL. ie: \"https://internalapp.yourcompany.com/oauth2/callback\"")
21
-
clientID=flag.String("client-id", "", "the Google OAuth Client ID: ie: \"123456.apps.googleusercontent.com\"")
22
-
clientSecret=flag.String("client-secret", "", "the OAuth Client Secret")
23
-
passBasicAuth=flag.Bool("pass-basic-auth", true, "pass HTTP Basic Auth information to upstream")
24
-
htpasswdFile=flag.String("htpasswd-file", "", "additionally authenticate against a htpasswd file. Entries must be created with \"htpasswd -s\" for SHA encryption")
25
-
cookieSecret=flag.String("cookie-secret", "", "the seed string for secure cookies")
26
-
cookieDomain=flag.String("cookie-domain", "", "an optional cookie domain to force cookies to")
27
-
cookieExpire=flag.Duration("cookie-expire", time.Duration(168)*time.Hour, "expire timeframe for cookie")
28
-
cookieHttpsOnly=flag.Bool("cookie-https-only", false, "set HTTPS only cookie")
29
-
authenticatedEmailsFile=flag.String("authenticated-emails-file", "", "authenticate against emails via file (one per line)")
30
-
googleAppsDomains=StringArray{}
31
-
upstreams=StringArray{}
13
+
"github.com/BurntSushi/toml"
14
+
"github.com/mreiferson/go-options"
32
15
)
33
16
34
-
funcinit() {
35
-
flag.Var(&googleAppsDomains, "google-apps-domain", "authenticate against the given google apps domain (may be given multiple times)")
36
-
flag.Var(&upstreams, "upstream", "the http url(s) of the upstream endpoint. If multiple, routing is based on path")
config:=flagSet.String("config", "", "path to config file")
24
+
showVersion:=flagSet.Bool("version", false, "print version string")
25
+
26
+
flagSet.String("http-address", "127.0.0.1:4180", "<addr>:<port> to listen on for HTTP clients")
27
+
flagSet.String("redirect-url", "", "the OAuth Redirect URL. ie: \"https://internalapp.yourcompany.com/oauth2/callback\"")
28
+
flagSet.Var(&upstreams, "upstream", "the http url(s) of the upstream endpoint. If multiple, routing is based on path")
29
+
flagSet.Bool("pass-basic-auth", true, "pass HTTP Basic Auth, X-Forwarded-User and X-Forwarded-Email information to upstream")
30
+
31
+
flagSet.Var(&googleAppsDomains, "google-apps-domain", "authenticate against the given Google apps domain (may be given multiple times)")
32
+
flagSet.String("client-id", "", "the Google OAuth Client ID: ie: \"123456.apps.googleusercontent.com\"")
33
+
flagSet.String("client-secret", "", "the OAuth Client Secret")
34
+
flagSet.String("authenticated-emails-file", "", "authenticate against emails via file (one per line)")
35
+
flagSet.String("htpasswd-file", "", "additionally authenticate against a htpasswd file. Entries must be created with \"htpasswd -s\" for SHA encryption")
40
36
41
-
flag.Parse()
37
+
flagSet.String("cookie-secret", "", "the seed string for secure cookies")
38
+
flagSet.String("cookie-domain", "", "an optional cookie domain to force cookies to (ie: .yourcompany.com)")
39
+
flagSet.Duration("cookie-expire", time.Duration(168)*time.Hour, "expire timeframe for cookie")
40
+
flagSet.Bool("cookie-https-only", false, "set HTTPS only cookie")
0 commit comments