git.iko.soy/typeable/oauth2-proxy
on master help sign in
Use session CreatedAt for cookie timings
commit2c566a5f5b65c3c6294a848ed51ddc7451a77d20 authorJoel Speed <Joel.speed@hotmail.co.uk> dateWed 15 May 2019, 17:08 (7 years ago) parent296d989
1 file changed+5−1
pkg/sessions/redis/redis_store.go+5−1
pkg/sessions/redis/redis_store.go+5−1
@@ -55,6 +55,10 @@ func NewRedisSessionStore(opts *options.SessionOptions, cookieOpts *options.Cook
5555// Save takes a sessions.SessionState and stores the information from it
5656// to redies, and adds a new ticket cookie on the HTTP response writer
5757func (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+
5862 // Old sessions that we are refreshing would have a request cookie
5963 // New sessions don't, so we ignore the error. storeValue will check requestCookie
6064 requestCookie, _ := req.Cookie(store.CookieOptions.CookieName)
@@ -73,7 +77,7 @@ func (store *SessionStore) Save(rw http.ResponseWriter, req *http.Request, s *se
7377 ticketString,
7478 store.CookieOptions,
7579 store.CookieOptions.CookieExpire,
76− time.Now(),
80+ s.CreatedAt,
7781 )
7882
7983 http.SetCookie(rw, ticketCookie)