From 2abf83f0be0065d746c4682da6bd7d5a17a481c8 Mon Sep 17 00:00:00 2001 From: Bolke de Bruin <bolke@xs4all.nl> Date: Sat, 22 Oct 2022 10:07:12 +0200 Subject: [PATCH] Set max session storage to 8kb If using the filesystem storage provider for session store it can be set than a larger value than 4kb as it is not tied to the restriction of a cookie anymore. --- cmd/rdpgw/web/session.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cmd/rdpgw/web/session.go b/cmd/rdpgw/web/session.go index fca4bc9..be79db7 100644 --- a/cmd/rdpgw/web/session.go +++ b/cmd/rdpgw/web/session.go @@ -9,9 +9,10 @@ import ( ) const ( - rdpGwSession = "RDPGWSESSION" - MaxAge = 120 - identityKey = "RDPGWID" + rdpGwSession = "RDPGWSESSION" + MaxAge = 120 + identityKey = "RDPGWID" + maxSessionLength = 8192 ) var sessionStore sessions.Store @@ -26,7 +27,13 @@ func InitStore(sessionKey []byte, encryptionKey []byte, storeType string) { if storeType == "file" { log.Println("Filesystem is used as session storage") - sessionStore = sessions.NewFilesystemStore(os.TempDir(), sessionKey, encryptionKey) + fs := sessions.NewFilesystemStore(os.TempDir(), sessionKey, encryptionKey) + + // set max length + log.Printf("Setting maximum session storage to %d bytes", maxSessionLength) + fs.MaxLength(maxSessionLength) + + sessionStore = fs } else { log.Println("Cookies are used as session storage") sessionStore = sessions.NewCookieStore(sessionKey, encryptionKey) -- GitLab