@@ -155,16 +155,12 @@ func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy {
155
155
redirectURL .Path = fmt .Sprintf ("%s/callback" , opts .ProxyPrefix )
156
156
157
157
log .Printf ("OAuthProxy configured for %s Client ID: %s" , opts .provider .Data ().ProviderName , opts .ClientID )
158
- domain := opts .CookieDomain
159
- if domain == "" {
160
- domain = "<default>"
161
- }
162
158
refresh := "disabled"
163
159
if opts .CookieRefresh != time .Duration (0 ) {
164
160
refresh = fmt .Sprintf ("after %s" , opts .CookieRefresh )
165
161
}
166
162
167
- log .Printf ("Cookie settings: name:%s secure(https):%v httponly:%v expiry:%s domain:%s refresh:%s" , opts .CookieName , opts .CookieSecure , opts .CookieHttpOnly , opts .CookieExpire , domain , refresh )
163
+ log .Printf ("Cookie settings: name:%s secure(https):%v httponly:%v expiry:%s domain:%s refresh:%s" , opts .CookieName , opts .CookieSecure , opts .CookieHttpOnly , opts .CookieExpire , opts . CookieDomain , refresh )
168
164
169
165
var cipher * cookie.Cipher
170
166
if opts .PassAccessToken || (opts .CookieRefresh != time .Duration (0 )) {
@@ -267,22 +263,21 @@ func (p *OAuthProxy) MakeCSRFCookie(req *http.Request, value string, expiration
267
263
}
268
264
269
265
func (p * OAuthProxy ) makeCookie (req * http.Request , name string , value string , expiration time.Duration , now time.Time ) * http.Cookie {
270
- domain := req .Host
271
- if h , _ , err := net .SplitHostPort (domain ); err == nil {
272
- domain = h
273
- }
274
266
if p .CookieDomain != "" {
267
+ domain := req .Host
268
+ if h , _ , err := net .SplitHostPort (domain ); err == nil {
269
+ domain = h
270
+ }
275
271
if ! strings .HasSuffix (domain , p .CookieDomain ) {
276
272
log .Printf ("Warning: request host is %q but using configured cookie domain of %q" , domain , p .CookieDomain )
277
273
}
278
- domain = p .CookieDomain
279
274
}
280
275
281
276
return & http.Cookie {
282
277
Name : name ,
283
278
Value : value ,
284
279
Path : "/" ,
285
- Domain : domain ,
280
+ Domain : p . CookieDomain ,
286
281
HttpOnly : p .CookieHttpOnly ,
287
282
Secure : p .CookieSecure ,
288
283
Expires : now .Add (expiration ),
0 commit comments