@@ -20,6 +20,7 @@ import (
2020 "github.com/coreos/go-oidc"
2121 "github.com/mbland/hmacauth"
2222 sessionsapi "github.com/pusher/oauth2_proxy/pkg/apis/sessions"
23+ "github.com/pusher/oauth2_proxy/pkg/cookies"
2324 "github.com/pusher/oauth2_proxy/pkg/encryption"
2425 "github.com/pusher/oauth2_proxy/pkg/logger"
2526 "github.com/pusher/oauth2_proxy/providers"
@@ -68,6 +69,7 @@ type OAuthProxy struct {
6869 CookieHTTPOnly bool
6970 CookieExpire time.Duration
7071 CookieRefresh time.Duration
72+ CookieSameSite string
7173 Validator func(string) bool
7274
7375 RobotsPath string
@@ -195,7 +197,7 @@ func NewWebSocketOrRestReverseProxy(u *url.URL, opts *Options, auth hmacauth.Hma
195197 }
196198}
197199
198−// NewOAuthProxy creates a new instance of OOuthProxy from the options provided
200+// NewOAuthProxy creates a new instance of OAuthProxy from the options provided
199201func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy {
200202 serveMux := http.NewServeMux()
201203 var auth hmacauth.HmacAuth
@@ -260,7 +262,7 @@ func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy {
260262 refresh = fmt.Sprintf("after %s", opts.CookieRefresh)
261263 }
262264
263− logger.Printf("Cookie settings: name:%s secure(https):%v httponly:%v expiry:%s domain:%s path:%s refresh:%s", opts.CookieName, opts.CookieSecure, opts.CookieHTTPOnly, opts.CookieExpire, opts.CookieDomain, opts.CookiePath, refresh)
265+ logger.Printf("Cookie settings: name:%s secure(https):%v httponly:%v expiry:%s domain:%s path:%s samesite:%s refresh:%s", opts.CookieName, opts.CookieSecure, opts.CookieHTTPOnly, opts.CookieExpire, opts.CookieDomain, opts.CookiePath, opts.CookieSameSite, refresh)
264266
265267 return &OAuthProxy{
266268 CookieName: opts.CookieName,
@@ -272,6 +274,7 @@ func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy {
272274 CookieHTTPOnly: opts.CookieHTTPOnly,
273275 CookieExpire: opts.CookieExpire,
274276 CookieRefresh: opts.CookieRefresh,
277+ CookieSameSite: opts.CookieSameSite,
275278 Validator: validator,
276279
277280 RobotsPath: "/robots.txt",
@@ -380,6 +383,7 @@ func (p *OAuthProxy) makeCookie(req *http.Request, name string, value string, ex
380383 HttpOnly: p.CookieHTTPOnly,
381384 Secure: p.CookieSecure,
382385 Expires: now.Add(expiration),
386+ SameSite: cookies.ParseSameSite(p.CookieSameSite),
383387 }
384388}
385389