SECURITY: store hashed session tokens

This commit is contained in:
Simon Martens
2025-05-29 03:20:35 +02:00
parent e0bb939764
commit 0d0918fb5d
4 changed files with 19 additions and 7 deletions

View File

@@ -32,7 +32,8 @@ func Authenticated(app core.App) func(*core.RequestEvent) error {
user, session, loaded := SESSION_CACHE.Get(cookie.Value)
if !loaded {
record, err := app.FindFirstRecordByData(dbmodels.SESSIONS_TABLE, dbmodels.SESSIONS_TOKEN_FIELD, cookie.Value)
hashedsession := dbmodels.HashStringSHA256(cookie.Value)
record, err := app.FindFirstRecordByData(dbmodels.SESSIONS_TABLE, dbmodels.SESSIONS_TOKEN_FIELD, hashedsession)
if err != nil {
e.SetCookie(deact_cookie)
e.Response.Header().Set("Clear-Site-Data", "\"cookies\"")