1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-06-15 00:15:00 +02:00

Adds failing test for using upstream Host header.

This commit is contained in:
John Boxall
2014-11-30 17:12:33 -08:00
committed by Jehiah Czebotar
parent ade9502dd2
commit 20a152261c
2 changed files with 41 additions and 1 deletions

View File

@ -46,6 +46,10 @@ type OauthProxy struct {
compiledRegex []*regexp.Regexp
}
func NewReverseProxy(target *url.URL) (proxy *httputil.ReverseProxy) {
return httputil.NewSingleHostReverseProxy(target)
}
func NewOauthProxy(opts *Options, validator func(string) bool) *OauthProxy {
login, _ := url.Parse("https://accounts.google.com/o/oauth2/auth")
redeem, _ := url.Parse("https://accounts.google.com/o/oauth2/token")
@ -54,7 +58,7 @@ func NewOauthProxy(opts *Options, validator func(string) bool) *OauthProxy {
path := u.Path
u.Path = ""
log.Printf("mapping path %q => upstream %q", path, u)
serveMux.Handle(path, httputil.NewSingleHostReverseProxy(u))
serveMux.Handle(path, NewReverseProxy(u))
}
for _, u := range opts.CompiledRegex {
log.Printf("compiled skip-auth-regex => %q", u)