git.iko.soy/typeable/oauth2-proxy
on master help sign in
Use session CreatedAt for cookie timings
2c566a5Joel Speed
pkg/sessions/redis/redis_store.go+5−1
@@ -55,6 +55,10 @@ func NewRedisSessionStore(opts *options.SessionOptions, cookieOpts *options.Cook
55// Save takes a sessions.SessionState and stores the information from it
55// Save takes a sessions.SessionState and stores the information from it
56// to redies, and adds a new ticket cookie on the HTTP response writer
56// to redies, and adds a new ticket cookie on the HTTP response writer
57func (store *SessionStore) Save(rw http.ResponseWriter, req *http.Request, s *sessions.SessionState) error {
57func (store *SessionStore) Save(rw http.ResponseWriter, req *http.Request, s *sessions.SessionState) error {
58+ if s.CreatedAt.IsZero() {
59+ s.CreatedAt = time.Now()
60+ }
61+
58 // Old sessions that we are refreshing would have a request cookie
62 // Old sessions that we are refreshing would have a request cookie
59 // New sessions don't, so we ignore the error. storeValue will check requestCookie
63 // New sessions don't, so we ignore the error. storeValue will check requestCookie
60 requestCookie, _ := req.Cookie(store.CookieOptions.CookieName)
64 requestCookie, _ := req.Cookie(store.CookieOptions.CookieName)
@@ -73,7 +77,7 @@ func (store *SessionStore) Save(rw http.ResponseWriter, req *http.Request, s *se
73 ticketString,
77 ticketString,
74 store.CookieOptions,
78 store.CookieOptions,
75 store.CookieOptions.CookieExpire,
79 store.CookieOptions.CookieExpire,
76− time.Now(),
80+ s.CreatedAt,
77 )
81 )
78
82
79 http.SetCookie(rw, ticketCookie)
83 http.SetCookie(rw, ticketCookie)