git.iko.soy/typeable/oauth2-proxy
on master help sign in
Merge pull request #35 from rogerhu/email
2f16534Jehiah Czebotar
oauthproxy.go+2−1
@@ -272,6 +272,7 @@ func (p *OauthProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
272
272
273 var ok bool
273 var ok bool
274 var user string
274 var user string
275+ var email string
275
276
276 if req.URL.Path == pingPath {
277 if req.URL.Path == pingPath {
277 p.PingPage(rw)
278 p.PingPage(rw)
@@ -343,7 +344,6 @@ func (p *OauthProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
343 if !ok {
344 if !ok {
344 cookie, err := req.Cookie(p.CookieKey)
345 cookie, err := req.Cookie(p.CookieKey)
345 if err == nil {
346 if err == nil {
346− var email string
347 email, ok = validateCookie(cookie, p.CookieSeed)
347 email, ok = validateCookie(cookie, p.CookieSeed)
348 user = strings.Split(email, "@")[0]
348 user = strings.Split(email, "@")[0]
349 }
349 }
@@ -368,6 +368,7 @@ func (p *OauthProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
368 if *passBasicAuth {
368 if *passBasicAuth {
369 req.SetBasicAuth(user, "")
369 req.SetBasicAuth(user, "")
370 req.Header["X-Forwarded-User"] = []string{user}
370 req.Header["X-Forwarded-User"] = []string{user}
371+ req.Header["X-Forwarded-Email"] = []string{email}
371 }
372 }
372
373
373 p.serveMux.ServeHTTP(rw, req)
374 p.serveMux.ServeHTTP(rw, req)