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
+88-16Lines changed: 88 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@
8
8
9
9
An SSO solution for Nginx using the [auth_request](http://nginx.org/en/docs/http/ngx_http_auth_request_module.html) module. Vouch Proxy can protect all of your websites at once.
10
10
11
-
Vouch Proxy supports many OAuth login providers and can enforce authentication to...
11
+
Vouch Proxy supports many OAuth and OIDC login providers and can enforce authentication to...
-[Compiling from source and running the binary](#compiling-from-source-and-running-the-binary)
45
+
-[/login and /logout endpoint redirection](#-login-and--logout-endpoint-redirection)
46
+
-[Troubleshooting, Support and Feature Requests](#troubleshooting--support-and-feature-requests--read-this-before-submitting-an-issue-at-github-)
47
+
(Read this before submitting an issue at GitHub)
48
+
-[I'm getting an infinite redirect loop which returns me to my IdP (Google/Okta/GitHub/...)](#i-m-getting-an-infinite-redirect-loop-which-returns-me-to-my-idp--google-okta-github--)
49
+
-[Okay, I looked at the issues and have tried some things with my configs but it's still not working](#okay--i-looked-at-the-issues-and-have-tried-some-things-with-my-configs-but-it-s-still-not-working)
50
+
-[submitting a Pull Request for a new feature](#submitting-a-pull-request-for-a-new-feature)
51
+
-[Advanced Authorization Using OpenResty](#advanced-authorization-using-openresty)
52
+
-[The flow of login and authentication using Google Oauth](#the-flow-of-login-and-authentication-using-google-oauth)
53
+
54
+
---
55
+
33
56
## What Vouch Proxy Does...
34
57
35
58
Vouch Proxy (VP) forces visitors to login and authenticate with an [IdP](https://en.wikipedia.org/wiki/Identity_provider) (such as one of the services listed above) before allowing them access to a website.
@@ -173,17 +196,45 @@ The variable `VOUCH_CONFIG` can be used to set an alternate location for the con
173
196
174
197
## More advanced configurations
175
198
199
+
All Vouch Proxy configuration items are documented in [config/config.yml_example](https://github.com/vouch/vouch-proxy/blob/master/config/config.yml_example)
200
+
176
201
-[cacheing of the Vouch Proxy validation response in Nginx](https://github.com/vouch/vouch-proxy/issues/76#issuecomment-464028743)
177
202
-[handleing `OPTIONS` requests when protecting an API with Vouch Proxy](https://github.com/vouch/vouch-proxy/issues/216)
178
203
-[validation by GitHub Team or GitHub Org](https://github.com/vouch/vouch-proxy/pull/205)
179
204
-[running on a Raspberry Pi using the ARM based Docker image](https://github.com/vouch/vouch-proxy/pull/247)
180
205
-[Kubernetes architecture post ingress](https://github.com/vouch/vouch-proxy/pull/263#issuecomment-628297832)
181
206
-[set `HTTP_PROXY` to relay Vouch Proxy IdP requests through an outbound proxy server](https://github.com/vouch/vouch-proxy/issues/291)
182
207
-[Reverse Proxy for Google Cloud Run Services](https://github.com/karthikv2k/oauth_reverse_proxy)
208
+
-[Enable native TLS in Vouch Proxy](https://github.com/vouch/vouch-proxy/pull/332#issue-522612010)
183
209
184
210
Please do help us to expand this list.
185
211
186
-
All Vouch Proxy configuration items are documented in [config/config.yml_example](https://github.com/vouch/vouch-proxy/blob/master/config/config.yml_example)
212
+
### Scopes and Claims
213
+
214
+
With Vouch Proxy you can request various `scopes` (standard and custom) to obtain more information about the user or gain access to the provider's APIs. Internally, Vouch Proxy launches a requests to `user_info_url` after successful authentication. From the provider's response the required `claims` are extracted and stored in the vouch cookie.
215
+
216
+
⚠️ **Additional claims and tokens will be added to the VP cookie and can make it large**
217
+
218
+
The VP cookie may get split up into several cookies, but if you need it, you need it. Large cookies and headers require Nginx to be configured with larger buffers. See [large_client_header_buffers](http://nginx.org/en/docs/http/ngx_http_core_module.html#large_client_header_buffers) and [proxy_buffer_size](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffer_size) for more information.
219
+
220
+
#### Setup `scopes` and `claims` in Vouch Proxy with Nginx
221
+
222
+
0. Configure Vouch Proxy for Nginx and your IdP as normal (See: [Installation and Configuration](#installation-and-configuration))
223
+
224
+
1. Set the necessary `scope`s in the `oauth` section of the vouch-proxy `config.yml` ([example config](config/config.yml_example_scopes_and_claims))
225
+
1. set `idtoken: X-Vouch-IdP-IdToken` in the `headers` section of vouch-proxy's `config.yml`
226
+
2. log in and call the `/validate` endpoint in a modern browser
227
+
3. check the response header for a `X-Vouch-IdP-IdToken` header
228
+
4. copy the value of the header into the debugger at https://jwt.io/ and ensure that the necessary claims are part of the jwt
229
+
5. if they are not, you need to adjust the `scopes` in the `oauth` section of your `config.yml` or reconfigure your oauth provider
230
+
2. Set the necessary `claims` in the `header` section of the vouch-proxy `config.yml`
231
+
1. log in and call the `/validate` endpoint in a modern browser
232
+
2. check the response headers for headers of the form `X-Vouch-Idp-Claims-<ClaimName>`
233
+
3. If they are not there clear your cookies and cached browser data
234
+
4. 🐞 If they are still not there but exist in the jwt (esp. custom claims) there might be a bug
235
+
5. remove the `idtoken: X-Vouch-IdP-IdToken` from the `headers` section of vouch-proxy's `config.yml` if you don't need it
236
+
3. Use `auth_request_set` after `auth_request` inside the protected location in the nginx [`server.conf`](examples/nginx/nginx_scopes_and_claims.conf)
237
+
4. Consume the claim ([example nginx config](examples/nginx/nginx_scopes_and_claims.conf))
187
238
188
239
## Running from Docker
189
240
@@ -219,7 +270,7 @@ Automated container builds for each Vouch Proxy release are available from [Dock
219
270
220
271
## Kubernetes Nginx Ingress
221
272
222
-
If you are using kubernetes with [nginx-ingress](https://github.com/kubernetes/ingress-nginx), you can configure your ingress with the following annotations (note quoting the auth-signin annotation):
273
+
If you are using kubernetes with [nginx-ingress](https://github.com/kubernetes/ingress-nginx), you can configure your ingress with the following annotations (note quoting the `auth-signin` annotation):
@@ -244,7 +295,7 @@ Helm Charts are maintained by [halkeye](https://github.com/halkeye) and are avai
244
295
245
296
## /login and /logout endpoint redirection
246
297
247
-
As of `v0.11.0`we have put additional checks in place to reduce [the attack surface of url redirection](https://blog.detectify.com/2019/05/16/the-real-impact-of-an-open-redirect/).
298
+
As of `v0.11.0` additional checks are in place to reduce [the attack surface of url redirection](https://blog.detectify.com/2019/05/16/the-real-impact-of-an-open-redirect/).
248
299
249
300
### /login?url=POST_LOGIN_URL
250
301
@@ -320,14 +371,35 @@ If you continue to have trouble, try the following:
320
371
321
372
Please [submit a new issue](https://github.com/vouch/vouch-proxy/issues) in the following fashion..
322
373
374
+
TLDR:
375
+
376
+
- set `vouch.testing: true`
377
+
- set `vouch.logLevel: debug`
378
+
- conduct a full round trip of `./vouch-proxy` capturing the output..
379
+
- VP startup
380
+
- `/validate`
381
+
- `/login`- even if the error is here
382
+
- `/auth`
383
+
- `/validate`- capture everything
384
+
- put all your logs and config in a `gist`.
385
+
- `./do.sh bug_report`is your friend
386
+
387
+
#### But read this anyways because we'll ask you to read it if you don't follow these instruction. :)
388
+
323
389
- **turn on `vouch.testing: true`** and set `vouch.logLevel: debug`.
324
-
- use [hasteb.in](https://hasteb.in/), or another **paste service** or a [gist](https://gist.github.com/) to provide your logs and config. **_DO NOT PUT YOUR LOGS AND CONFIG INTO THE GITHUB ISSUE_**. Using a paste service is important as it will maintain spacing and will provide line numbers and formatting. We are hunting for needles in haystacks with setups with several moving parts, these features help considerably. Paste services save your time and our time and help us to help you quickly. You're more likely to get good support from us in a timely manner by following this advice.
325
-
- run `./do.sh bug_report yourdomain.com [yourotherdomain.com]` which will create a redacted version of your config and logs
390
+
- use a [gist](https://gist.github.com/) or another **paste service** such as [hasteb.in](https://hasteb.in/). **_DO NOT PUT YOUR LOGS AND CONFIG INTO THE GITHUB ISSUE_**. Using a paste service is important as it will maintain spacing and will provide line numbers and formatting. We are hunting for needles in haystacks with setups with several moving parts, these features help considerably. Paste services save your time and our time and help us to help you quickly. You're more likely to get good support from us in a timely manner by following this advice.
391
+
- run `./do.sh bug_report secretdomain.com secretpass [anothersecret..]` which will create a redacted version of your config and logs removing each of those strings
326
392
- and follow the instructions at the end to redact your Nginx config
327
-
- all of those go into [hasteb.in](https://hasteb.in/) or a [gist](https://gist.github.com/)
393
+
- all of those go into a [gist](https://gist.github.com/)
328
394
- then [open a new issue](https://github.com/vouch/vouch-proxy/issues/new) in this repository
329
395
- or visit our IRC channel [#vouch](irc://freenode.net/#vouch) on freenode
330
396
397
+
A bug report can be generated from a docker environment using the `voucher/vouch-proxy:alpine` image...
- recieves the request for private.oursites.com from Bob via Nginx `proxy_pass`
372
-
- it looks for a cookie named "oursitesSSO" that contains a JWT
444
+
- looks for a cookie named "oursitesSSO" that contains a JWT
373
445
- if the cookie is found, and the JWT is valid
374
-
- returns 200 to Nginx, which will allow access (bob notices nothing)
446
+
- returns `200 OK` to Nginx, which will allow access (bob notices nothing)
375
447
- if the cookie is NOT found, or the JWT is NOT valid
376
-
- return 401 NotAuthorized to Nginx (which forwards the request on to login)
448
+
- return `401 NotAuthorized` to Nginx (which forwards the request on to login)
377
449
378
450
- Bob is first forwarded briefly to `https://vouch.oursites.com/login?url=https://private.oursites.com`
379
451
380
452
- clears out the cookie named "oursitesSSO" if it exists
381
453
- generates a nonce and stores it in session variable \$STATE
382
-
- stores the url `https://private.oursites.com` from the query string in session variable \$requestedURL
383
-
- respond to Bob with a 302 redirect to Google's OAuth Login form, including the \$STATE nonce
454
+
- stores the url `https://private.oursites.com` from the query string in session variable `$requestedURL`
455
+
- respond to Bob with a 302 redirect to Google's OAuth Login form, including the `$STATE` nonce
384
456
385
457
- Bob logs into his Google account using Oauth
386
458
@@ -389,13 +461,13 @@ OpenResty and configs for a variety of scenarios are available in the [examples]
389
461
390
462
- Bob is forwarded to `https://vouch.oursites.com/auth?state=$STATE`
391
463
- if the \$STATE nonce from the url matches the session variable "state"
392
-
- make a "third leg" request of google (server to server) to exchange the OAuth code for Bob's user info including email address bob@oursites.com
464
+
- make a "third leg" request of Google (server to server) to exchange the OAuth code for Bob's user info including email address bob@oursites.com
393
465
- if the email address matches the domain oursites.com (it does)
394
466
- issue bob a JWT in the form of a cookie named "oursitesSSO"
395
-
- retrieve the session variable $requestedURL and 302 redirect bob back to $requestedURL
467
+
- retrieve the session variable `$requestedURL` and 302 redirect bob back to `https://private.oursites.com`
396
468
397
469
Note that outside of some innocuos redirection, Bob only ever sees `https://private.oursites.com` and the Google Login screen in his browser. While Vouch does interact with Bob's browser several times, it is just to set cookies, and if the 302 redirects work properly Bob will log in quickly.
398
470
399
471
Once the JWT is set, Bob will be authorized for all other sites which are configured to use `https://vouch.oursites.com/validate` from the `auth_request` Nginx module.
400
472
401
-
The next time Bob is forwarded to google for login, since he has already authorized the Vouch OAuth app, Google immediately forwards him back and sets the cookie and sends him on his merry way. Bob may not even notice that he logged in via Vouch.
473
+
The next time Bob is forwarded to google for login, since he has already authorized the Vouch Proxy OAuth app, Google immediately forwards him back and sets the cookie and sends him on his merry way. In some browsers such as Chrome, Bob may not even notice that he logged in using Vouch Proxy.
echo -e "\tcat nginx.conf | sed 's/yourdomain.com/DOMAIN.COM/g'\n"
128
-
echo -e "Please upload both configs and some logs to https://hastebin.com/ and open an issue on GitHub at https://github.com/vouch/vouch-proxy/issues\n"
130
+
echo -e "Please upload configs and logs to a gist and open an issue on GitHub at https://github.com/vouch/vouch-proxy/issues\n"
129
131
}
130
132
131
133
_redact() {
@@ -318,6 +320,17 @@ gosec() {
318
320
# segfault's without exec since it would just call this function infinitely :)
0 commit comments