Circular dependancy issue when working on hardening

This commit is contained in:
2025-03-25 16:43:16 +00:00
parent 1a531af4f8
commit b58a8bdb82
8 changed files with 96 additions and 23 deletions

23
helpers/session.go Normal file
View File

@@ -0,0 +1,23 @@
package helpers
import (
"net/http"
"github.com/gorilla/sessions"
)
var store = sessions.NewCookieStore([]byte("super-secret-key")) // move this here
func init() {
store.Options = &sessions.Options{
Path: "/",
MaxAge: 86400 * 1,
HttpOnly: true,
Secure: true,
SameSite: http.SameSiteStrictMode,
}
}
func GetSession(w http.ResponseWriter, r *http.Request) (*sessions.Session, error) {
return store.Get(r, "session-name")
}