Skip to content

Commit

Permalink
Add X-Forwarded-Proto header
Browse files Browse the repository at this point in the history
Guess protocol from redirect-url scheme if present, or from
cookie-secure flag value.

closes bitly#171
  • Loading branch information
Artyom Pervukhin authored and chen-anders committed Jan 30, 2017
1 parent 80ffaae commit fe92aa2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions oauthproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,14 @@ func (p *OAuthProxy) Authenticate(rw http.ResponseWriter, req *http.Request) int
} else {
rw.Header().Set("GAP-Auth", session.Email)
}
switch {
case p.redirectURL.Scheme != "":
req.Header.Set("X-Forwarded-Proto", p.redirectURL.Scheme)
case p.CookieSecure:
req.Header.Set("X-Forwarded-Proto", "https")
default:
req.Header.Set("X-Forwarded-Proto", "http")
}
return http.StatusAccepted
}

Expand Down

0 comments on commit fe92aa2

Please sign in to comment.