From 82c514b11a7493457ca2915562012a605fac28eb Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Mon, 30 Mar 2026 16:10:11 +0200 Subject: [PATCH] Ease samesite cookie settings Entire-Checkpoint: 2fe286e23a4a --- internal/auth/auth.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 327e48a3..d1c004bd 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -164,12 +164,17 @@ func (auth *Authentication) AuthViaSession( return nil, errors.New("invalid session data") } + authSourceInt, ok := session.Values["authSource"].(int) + if !ok { + authSourceInt = int(schema.AuthViaLocalPassword) + } + return &schema.User{ Username: username, Projects: projects, Roles: roles, AuthType: schema.AuthSession, - AuthSource: -1, + AuthSource: schema.AuthSource(authSourceInt), }, nil } @@ -319,10 +324,11 @@ func (auth *Authentication) SaveSession(rw http.ResponseWriter, r *http.Request, } session.Options.Secure = false } - session.Options.SameSite = http.SameSiteStrictMode + session.Options.SameSite = http.SameSiteLaxMode session.Values["username"] = user.Username session.Values["projects"] = user.Projects session.Values["roles"] = user.Roles + session.Values["authSource"] = int(user.AuthSource) if err := auth.sessionStore.Save(r, rw, session); err != nil { cclog.Warnf("session save failed: %s", err.Error()) http.Error(rw, err.Error(), http.StatusInternalServerError)