@@ -12,6 +12,7 @@ import (
1212 "net/url"
1313 "strings"
1414 "time"
15+ "regexp"
1516
1617 "github.com/bitly/go-simplejson"
1718)
@@ -40,6 +41,8 @@ type OauthProxy struct {
4041 DisplayHtpasswdForm bool
4142 serveMux *http.ServeMux
4243 PassBasicAuth bool
44+ skipAuthRegex []string
45+ compiledRegex []*regexp.Regexp
4346}
4447
4548func NewOauthProxy(opts *Options, validator func(string) bool) *OauthProxy {
@@ -52,6 +55,10 @@ func NewOauthProxy(opts *Options, validator func(string) bool) *OauthProxy {
5255 log.Printf("mapping path %q => upstream %q", path, u)
5356 serveMux.Handle(path, httputil.NewSingleHostReverseProxy(u))
5457 }
58+ for _, u := range opts.CompiledRegex {
59+ log.Printf("compiled skip-auth-regex => %q", u)
60+ }
61+
5562 redirectUrl := opts.redirectUrl
5663 redirectUrl.Path = oauthCallbackPath
5764
@@ -76,6 +83,8 @@ func NewOauthProxy(opts *Options, validator func(string) bool) *OauthProxy {
7683 oauthLoginUrl: login,
7784 serveMux: serveMux,
7885 redirectUrl: redirectUrl,
86+ skipAuthRegex: opts.SkipAuthRegex,
87+ compiledRegex: opts.CompiledRegex,
7988 PassBasicAuth: opts.PassBasicAuth,
8089 }
8190}
@@ -299,6 +308,15 @@ func (p *OauthProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
299308 return
300309 }
301310
311+ for _, u := range p.compiledRegex {
312+ match := u.MatchString(req.URL.Path)
313+ if match {
314+ p.serveMux.ServeHTTP(rw, req)
315+ return
316+ }
317+
318+ }
319+
302320 if req.URL.Path == signInPath {
303321 redirect, err := p.GetRedirect(req)
304322 if err != nil {