diff pkg/auth/store.go @ 2639:0db742c7813d

Make session timeout configurable Useful e.g. for testing, long running scripts, coping with a client clock which is more than 3 hours fast and maybe more. Even configuring a timeout <= 0 might be useful to actually prevent clients from doing anything.
author Tom Gottfried <tom@intevation.de>
date Thu, 14 Mar 2019 11:15:43 +0100
parents 9e0beb373690
children 7cccf7fef3e8
line wrap: on
line diff
--- a/pkg/auth/store.go	Thu Mar 14 10:50:18 2019 +0100
+++ b/pkg/auth/store.go	Thu Mar 14 11:15:43 2019 +0100
@@ -19,6 +19,7 @@
 	"log"
 	"time"
 
+	"gemma.intevation.de/gemma/pkg/config"
 	bolt "github.com/etcd-io/bbolt"
 )
 
@@ -207,7 +208,7 @@
 			ss.remove(token)
 			newToken := generateSessionKey()
 			// TODO: Ensure that this is not racy!
-			session.ExpiresAt = time.Now().Add(maxTokenValid).Unix()
+			session.ExpiresAt = time.Now().Add(config.SessionTimeout()).Unix()
 			ss.sessions[newToken] = session
 			ss.store(newToken, session)
 			resCh <- result{newToken: newToken}