mirror of
https://github.com/thomiceli/opengist.git
synced 2025-07-09 01:18:04 +02:00
Refactor server code (#407)
This commit is contained in:
28
internal/web/context/store.go
Normal file
28
internal/web/context/store.go
Normal file
@ -0,0 +1,28 @@
|
||||
package context
|
||||
|
||||
import (
|
||||
"github.com/gorilla/sessions"
|
||||
"github.com/markbates/goth/gothic"
|
||||
"github.com/thomiceli/opengist/internal/config"
|
||||
"github.com/thomiceli/opengist/internal/session"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type Store struct {
|
||||
sessionsPath string
|
||||
|
||||
flashStore *sessions.CookieStore
|
||||
UserStore *sessions.FilesystemStore
|
||||
}
|
||||
|
||||
func NewStore(sessionsPath string) *Store {
|
||||
s := &Store{sessionsPath: sessionsPath}
|
||||
|
||||
s.flashStore = sessions.NewCookieStore([]byte("opengist"))
|
||||
encryptKey, _ := session.GenerateSecretKey(filepath.Join(s.sessionsPath, "session-encrypt.key"))
|
||||
s.UserStore = sessions.NewFilesystemStore(s.sessionsPath, config.SecretKey, encryptKey)
|
||||
s.UserStore.MaxLength(10 * 1024)
|
||||
gothic.Store = s.UserStore
|
||||
|
||||
return s
|
||||
}
|
Reference in New Issue
Block a user