Skip to content

Commit

Permalink
support combo of --set-xauthrequest and --pass-access-token
Browse files Browse the repository at this point in the history
in this case return access token in auth-request response header
  • Loading branch information
patrickfuller authored and ploxiln committed Nov 22, 2018
1 parent d626dbc commit ca91779
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ server {
proxy_set_header X-User $user;
proxy_set_header X-Email $email;
# if you enabled --pass-access-token, this will pass the token to the backend
auth_request_set $token $upstream_http_x_auth_request_access_token;
proxy_set_header X-Token $token;
# if you enabled --cookie-refresh, this is needed for it to work with auth_request
auth_request_set $auth_cookie $upstream_http_set_cookie;
add_header Set-Cookie $auth_cookie;
Expand Down
3 changes: 3 additions & 0 deletions oauthproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,9 @@ func (p *OAuthProxy) Authenticate(rw http.ResponseWriter, req *http.Request) int
if session.Email != "" {
rw.Header().Set("X-Auth-Request-Email", session.Email)
}
if p.PassAccessToken && session.AccessToken != "" {
rw.Header().Set("X-Auth-Request-Access-Token", session.AccessToken)
}
}
if p.PassAccessToken && session.AccessToken != "" {
req.Header["X-Forwarded-Access-Token"] = []string{session.AccessToken}
Expand Down

0 comments on commit ca91779

Please sign in to comment.