Use filesystem session store (#240)

This commit is contained in:
Thomas Miceli
2024-04-03 01:48:31 +02:00
parent ef004675a5
commit a97d9cdbf4
6 changed files with 48 additions and 10 deletions

View File

@ -35,10 +35,11 @@ import (
)
var (
dev bool
store *sessions.CookieStore
re = regexp.MustCompile("[^a-z0-9]+")
fm = template.FuncMap{
dev bool
flashStore *sessions.CookieStore // session store for flash messages
userStore *sessions.FilesystemStore // session store for user sessions
re = regexp.MustCompile("[^a-z0-9]+")
fm = template.FuncMap{
"split": strings.Split,
"indexByte": strings.IndexByte,
"toInt": func(i string) int {
@ -160,8 +161,13 @@ type Server struct {
func NewServer(isDev bool) *Server {
dev = isDev
store = sessions.NewCookieStore([]byte("opengist"))
gothic.Store = store
flashStore = sessions.NewCookieStore([]byte("opengist"))
userStore = sessions.NewFilesystemStore(path.Join(config.GetHomeDir(), "sessions"),
utils.ReadKey(path.Join(config.GetHomeDir(), "sessions", "session-auth.key")),
utils.ReadKey(path.Join(config.GetHomeDir(), "sessions", "session-encrypt.key")),
)
userStore.MaxLength(10 * 1024)
gothic.Store = userStore
e := echo.New()
e.HideBanner = true