mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
Auth flow fixes (#82)
* preliminary fixes to broken auth flow * fix some auth/cookie weirdness * fmt
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user