test(auth): reconcile db_sessions with LC-514 hashed session id #497
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/LC-520-db-sessions-hashed-id-tests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
LC-514 (PR #496) hashed session tokens at rest:
create_session*now storesSHA-256(token)assessions.idand returns the raw cookie token, soSessionRow.idis the hash and every production lookup hashes the presented cookie before the WHERE (get_user_by_session,touch_session_last_seen,delete_session*, and the settingsis_current/ revoke paths). Production is internally consistent, butserver/tests/db_sessions.rsstill assumedsessions.id == raw tokenand was not reconciled, so three tests failed onmain(b271392): the list correlation (find r.id == a1), the expiry-filterUPDATE ... WHERE id = ?, and the touch-last-seen correlation each compared a raw token against a hashed id. That leftjust testred, and the mandatory pre-commit gate (just pre-commit->check test) aborted every commit, blocking all repo work (LC-515 in particular).This reconciles the three tests to the hashed-id contract via the existing public
db::auth::hash_session_tokenhelper, correlating sessions by the hash the same way the settings UI does. No production change: fixing this inserver/src/would re-introduce the plaintext-cookie-at-rest vulnerability LC-514 closed.delete_session_for_user_is_user_scopedalready passed becausedelete_session_for_userruns the presented value throughlookup_session_id(which hashes a raw token). Comments record the contract so the hash-based correlation is not mistaken for a bug later.Verification (containerized
./dev/cargo):db_sessions4/4 pass; fulljust pre-commit(check +just test) green (163/163 test binaries ok, clippy standalone+saas, fmt);just test-saasgreen.This is the prerequisite for LC-515 (migration-immutability guard), which is blocked until
mainis green again.Fixes LC-520.