summaryrefslogtreecommitdiff
path: root/internal/router/session.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/router/session.go')
-rw-r--r--internal/router/session.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/internal/router/session.go b/internal/router/session.go
index a1ac09d28..2d00f7677 100644
--- a/internal/router/session.go
+++ b/internal/router/session.go
@@ -22,6 +22,7 @@ import (
"crypto/rand"
"errors"
"fmt"
+ "net/http"
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/memstore"
@@ -63,6 +64,14 @@ func useSession(cfg *config.Config, dbService db.DB, engine *gin.Engine) error {
}
store := memstore.NewStore(rs.Auth, rs.Crypt)
+ store.Options(sessions.Options{
+ Path: "/",
+ Domain: cfg.Host,
+ MaxAge: 120, // 2 minutes
+ Secure: true, // only use cookie over https
+ HttpOnly: true, // exclude javascript from inspecting cookie
+ SameSite: http.SameSiteStrictMode, // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-cookie-same-site-00#section-4.1.1
+ })
sessionName := fmt.Sprintf("gotosocial-%s", cfg.Host)
engine.Use(sessions.Sessions(sessionName, store))
return nil