mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-03-30 20:47:31 +02:00
Ease samesite cookie settings
Entire-Checkpoint: 2fe286e23a4a
This commit is contained in:
@@ -164,12 +164,17 @@ func (auth *Authentication) AuthViaSession(
|
|||||||
return nil, errors.New("invalid session data")
|
return nil, errors.New("invalid session data")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
authSourceInt, ok := session.Values["authSource"].(int)
|
||||||
|
if !ok {
|
||||||
|
authSourceInt = int(schema.AuthViaLocalPassword)
|
||||||
|
}
|
||||||
|
|
||||||
return &schema.User{
|
return &schema.User{
|
||||||
Username: username,
|
Username: username,
|
||||||
Projects: projects,
|
Projects: projects,
|
||||||
Roles: roles,
|
Roles: roles,
|
||||||
AuthType: schema.AuthSession,
|
AuthType: schema.AuthSession,
|
||||||
AuthSource: -1,
|
AuthSource: schema.AuthSource(authSourceInt),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,10 +324,11 @@ func (auth *Authentication) SaveSession(rw http.ResponseWriter, r *http.Request,
|
|||||||
}
|
}
|
||||||
session.Options.Secure = false
|
session.Options.Secure = false
|
||||||
}
|
}
|
||||||
session.Options.SameSite = http.SameSiteStrictMode
|
session.Options.SameSite = http.SameSiteLaxMode
|
||||||
session.Values["username"] = user.Username
|
session.Values["username"] = user.Username
|
||||||
session.Values["projects"] = user.Projects
|
session.Values["projects"] = user.Projects
|
||||||
session.Values["roles"] = user.Roles
|
session.Values["roles"] = user.Roles
|
||||||
|
session.Values["authSource"] = int(user.AuthSource)
|
||||||
if err := auth.sessionStore.Save(r, rw, session); err != nil {
|
if err := auth.sessionStore.Save(r, rw, session); err != nil {
|
||||||
cclog.Warnf("session save failed: %s", err.Error())
|
cclog.Warnf("session save failed: %s", err.Error())
|
||||||
http.Error(rw, err.Error(), http.StatusInternalServerError)
|
http.Error(rw, err.Error(), http.StatusInternalServerError)
|
||||||
|
|||||||
Reference in New Issue
Block a user