@@ -10,8 +10,7 @@ import (
1010 "github.com/vouch/vouch-proxy/pkg/domains"
1111)
1212
13- var defaultMaxAge = cfg .GetInt ("JWT.MaxAge" ) * 60
14-
13+ var defaultMaxAge = cfg .Cfg .JWT .MaxAge * 60
1514
1615// SetCookie http
1716func SetCookie (w http.ResponseWriter , r * http.Request , val string ) {
@@ -25,25 +24,25 @@ func setCookie(w http.ResponseWriter, r *http.Request, val string, maxAge int) {
2524 }
2625 domain := domains .Matches (r .Host )
2726 // Allow overriding the cookie domain in the config file
28- if cfg .Get ( " Cookie.Domain" ) != "" {
29- domain = cfg .Get ( " Cookie.Domain" )
27+ if cfg .Cfg . Cookie .Domain != "" {
28+ domain = cfg .Cfg . Cookie .Domain
3029 log .Debugf ("setting the cookie domain to %v" , domain )
3130 }
3231 // log.Debugf("cookie %s expires %d", cfg.Cfg.Cookie.Name, expires)
3332 http .SetCookie (w , & http.Cookie {
34- Name : cfg .Get ( " Cookie.Name" ) ,
33+ Name : cfg .Cfg . Cookie .Name ,
3534 Value : val ,
3635 Path : "/" ,
3736 Domain : domain ,
3837 MaxAge : maxAge ,
39- Secure : cfg .GetBool ( " Cookie.Secure" ) ,
40- HttpOnly : cfg .GetBool ( " Cookie.HTTPOnly" ) ,
38+ Secure : cfg .Cfg . Cookie .Secure ,
39+ HttpOnly : cfg .Cfg . Cookie .HTTPOnly ,
4140 })
4241}
4342
4443// Cookie get the vouch jwt cookie
4544func Cookie (r * http.Request ) (string , error ) {
46- cookie , err := r .Cookie (cfg .Get ( " Cookie.Name" ) )
45+ cookie , err := r .Cookie (cfg .Cfg . Cookie .Name )
4746 if err != nil {
4847 return "" , err
4948 }
@@ -52,7 +51,7 @@ func Cookie(r *http.Request) (string, error) {
5251 }
5352
5453 log .WithFields (log.Fields {
55- "cookieName" : cfg .Get ( " Cookie.Name" ) ,
54+ "cookieName" : cfg .Cfg . Cookie .Name ,
5655 "cookieValue" : cookie .Value ,
5756 }).Debug ("cookie" )
5857 return cookie .Value , err
0 commit comments