@@ -68,6 +68,7 @@ type OAuthProxy struct {
6868 PassAccessToken bool
6969 CookieCipher *cookie.Cipher
7070 skipAuthRegex []string
71+ skipAuthPreflight bool
7172 compiledRegex []*regexp.Regexp
7273 templates *template.Template
7374 Footer string
@@ -198,6 +199,7 @@ func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy {
198199 serveMux: serveMux,
199200 redirectURL: redirectURL,
200201 skipAuthRegex: opts.SkipAuthRegex,
202+ skipAuthPreflight: opts.SkipAuthPreflight,
201203 compiledRegex: opts.CompiledRegex,
202204 SetXAuthRequest: opts.SetXAuthRequest,
203205 PassBasicAuth: opts.PassBasicAuth,
@@ -421,6 +423,11 @@ func (p *OAuthProxy) GetRedirect(req *http.Request) (redirect string, err error)
421423 return
422424}
423425
426+func (p *OAuthProxy) IsWhitelistedRequest(req *http.Request) (ok bool) {
427+ isPreflightRequestAllowed := p.skipAuthPreflight && req.Method == "OPTIONS"
428+ return isPreflightRequestAllowed || p.IsWhitelistedPath(req.URL.Path)
429+}
430+
424431func (p *OAuthProxy) IsWhitelistedPath(path string) (ok bool) {
425432 for _, u := range p.compiledRegex {
426433 ok = u.MatchString(path)
@@ -445,7 +452,7 @@ func (p *OAuthProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
445452 p.RobotsTxt(rw)
446453 case path == p.PingPath:
447454 p.PingPage(rw)
448− case p.IsWhitelistedPath(path):
455+ case p.IsWhitelistedRequest(req):
449456 p.serveMux.ServeHTTP(rw, req)
450457 case path == p.SignInPath:
451458 p.SignIn(rw, req)