-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Forwarding Google OAuth user information through nginx #420
Comments
I spent some time looking at this, but haven't gotten anywhere yet. Following the pattern, this should work:
However, it doesn't. The code that sets headers is here, and it looks like it sets differently than |
There are two modes in which In the short term, you could use New options, or new meanings for the existing options, would be needed to pass more information in the response for "auth_request" mode. Perhaps if |
Thanks for getting back to me. Could you clarify what's involved with running in original proxy mode? If I have to move away from nginx, then it seems like a lot of config. However, it seems that I could get around it by patching More generally, it looks like the proxy already fetches user info from google. Maybe I could grab that and store as a header or cookie? |
"original proxy mode" is often used with nginx as well, and that's even shown in the first diagram: https://github.com/bitly/oauth2_proxy#architecture These are like lego pieces. You can put either one in front or behind. It's easy. You could certainly add whatever information you want to response headers. Those changes would just not be likely to be accepted upstream. |
It's likely my own ignorance, but re-ordering the legos seemed like it would be a headache (SSL termination, multiple endpoints, etc.). At least for now, I went the patch route. See below. Regarding getting accepted upstream, do you think the diff below would be a viable pull request? It's a non-breaking change, and (in my opinion) makes the oauth_token.patch diff --git a/oauthproxy.go b/oauthproxy.go
index dd2b58e..19ed0e3 100644
--- a/oauthproxy.go
+++ b/oauthproxy.go
@@ -680,6 +680,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} Dockerfile
nginx.conf
|
I think those three lines, to make |
I'll make the PR and let the maintainers figure it out. Thanks for the help! |
I'm running oauth2_proxy and nginx in two docker containers, and it's working great as an authentication layer. However, I don't know how to reliably forward google user information (full name, profile picture) through to the endpoint.
In my oauth2_proxy config file, I have:
In nginx, I have:
The user headers help, but are not all the information I'm looking for.
I could GET the desired info with an access token, but the
pass_access_token
doesn't work as is. Likely because I'm not forwarding it through nginx, but I can't find any documentation on appending theX-Forwarded-Access-Token
.What am I missing?
Thanks,
Pat
The text was updated successfully, but these errors were encountered: