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.
This commit is contained in:
Bolke de Bruin 2022-10-22 10:07:12 +02:00
parent 236ddb4f9b
commit 2abf83f0be

View File

@ -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)