@@ -24,13 +24,13 @@ const oauthStartPath = "/oauth2/start"
2424const oauthCallbackPath = "/oauth2/callback"
2525
2626type OauthProxy struct {
27- CookieSeed string
28- CookieKey string
29- CookieDomain string
30- CookieHttpsOnly bool
31- CookieHttpOnly bool
32- CookieExpire time.Duration
33- Validator func (string ) bool
27+ CookieSeed string
28+ CookieKey string
29+ CookieDomain string
30+ CookieSecure bool
31+ CookieHttpOnly bool
32+ CookieExpire time.Duration
33+ Validator func (string ) bool
3434
3535 redirectUrl * url.URL // the url to receive requests at
3636 oauthRedemptionUrl * url.URL // endpoint to redeem the code
@@ -98,15 +98,21 @@ func NewOauthProxy(opts *Options, validator func(string) bool) *OauthProxy {
9898 if domain == "" {
9999 domain = "<default>"
100100 }
101- log .Printf ("Cookie settings: https_only (SSL required): %v httponly: %v expiry: %s domain:%s" , opts .CookieHttpsOnly , opts .CookieHttpOnly , opts .CookieExpire , domain )
101+ if ! opts .CookieHttpsOnly {
102+ log .Printf ("Warning: cookie-https-only setting is deprecated and will be removed in a future version. use cookie-secure" )
103+ opts .CookieSecure = opts .CookieHttpsOnly
104+ }
105+
106+ log .Printf ("Cookie settings: secure (https):%v httponly:%v expiry:%s domain:%s" , opts .CookieSecure , opts .CookieHttpOnly , opts .CookieExpire , domain )
107+
102108 return & OauthProxy {
103- CookieKey : "_oauthproxy" ,
104- CookieSeed : opts .CookieSecret ,
105- CookieDomain : opts .CookieDomain ,
106- CookieHttpsOnly : opts .CookieHttpsOnly ,
107- CookieHttpOnly : opts .CookieHttpOnly ,
108- CookieExpire : opts .CookieExpire ,
109- Validator : validator ,
109+ CookieKey : "_oauthproxy" ,
110+ CookieSeed : opts .CookieSecret ,
111+ CookieDomain : opts .CookieDomain ,
112+ CookieSecure : opts .CookieSecure ,
113+ CookieHttpOnly : opts .CookieHttpOnly ,
114+ CookieExpire : opts .CookieExpire ,
115+ Validator : validator ,
110116
111117 clientID : opts .ClientID ,
112118 clientSecret : opts .ClientSecret ,
@@ -130,7 +136,7 @@ func (p *OauthProxy) GetRedirectUrl(host string) string {
130136 var u url.URL
131137 u = * p .redirectUrl
132138 if u .Scheme == "" {
133- if p .CookieHttpsOnly {
139+ if p .CookieSecure {
134140 u .Scheme = "https"
135141 } else {
136142 u .Scheme = "http"
@@ -265,7 +271,7 @@ func (p *OauthProxy) SetCookie(rw http.ResponseWriter, req *http.Request, val st
265271 Path : "/" ,
266272 Domain : domain ,
267273 HttpOnly : p .CookieHttpOnly ,
268- Secure : p .CookieHttpsOnly ,
274+ Secure : p .CookieSecure ,
269275 Expires : time .Now ().Add (p .CookieExpire ),
270276 }
271277 http .SetCookie (rw , cookie )
0 commit comments