git.iko.soy/typeable/oauth2-proxy
on master help sign in
Access token forwarding through nginx auth request (#68)

* Access token forwarding through nginx auth request Related to #420. (cherry picked from commit b138872beaaa7f47d43a1c0fef11a67f57e61eff) Signed-off-by: David Holsgrove <david.holsgrove@biarri.com> * Improved documentation for auth request token (cherry picked from commit 6fab314f7203f4d652bb34247abb4e7cb497c41d) Signed-off-by: David Holsgrove <david.holsgrove@biarri.com> * Update README.md Example should set header as `X-Access-Token` Co-Authored-By: davidholsgrove <davidholsgrove@users.noreply.github.com> * Update Changelog to reference https://github.com/pusher/oauth2_proxy/pull/68 * Fix Changelog message location

commit2280b42f59036adb55083374fe86f904074f2d32 authorDavid Holsgrove <davidholsgrove@users.noreply.github.com> dateFri 22 Feb 2019, 17:49 (8 years ago) parentc833353
3 files changed+9
CHANGELOG.md+2 README.md+4 oauthproxy.go+3
CHANGELOG.md+2
@@ -2,6 +2,8 @@
22
33## Changes since v3.1.0
44
5+- [#68](https://github.com/pusher/oauth2_proxy/pull/68) forward X-Auth-Access-Token header (@davidholsgrove)
6+
57# v3.1.0
68
79## Release highlights
README.md+4
@@ -425,6 +425,10 @@ server {
425425 proxy_set_header X-User $user;
426426 proxy_set_header X-Email $email;
427427
428+ # if you enabled --pass-access-token, this will pass the token to the backend
429+ auth_request_set $token $upstream_http_x_auth_request_access_token;
430+ proxy_set_header X-Access-Token $token;
431+
428432 # if you enabled --cookie-refresh, this is needed for it to work with auth_request
429433 auth_request_set $auth_cookie $upstream_http_set_cookie;
430434 add_header Set-Cookie $auth_cookie;
oauthproxy.go+3
@@ -880,6 +880,9 @@ func (p *OAuthProxy) Authenticate(rw http.ResponseWriter, req *http.Request) int
880880 if session.Email != "" {
881881 rw.Header().Set("X-Auth-Request-Email", session.Email)
882882 }
883+ if p.PassAccessToken && session.AccessToken != "" {
884+ rw.Header().Set("X-Auth-Request-Access-Token", session.AccessToken)
885+ }
883886 }
884887 if p.PassAccessToken && session.AccessToken != "" {
885888 req.Header["X-Forwarded-Access-Token"] = []string{session.AccessToken}