Commit dea96f1
committed
Add HttpOnly, Secure, SameSite, and maxAge flags to session cookie
express-session was configured with no cookie options, leaving the
connect.sid session identifier readable via document.cookie (no
HttpOnly), transmittable over HTTP (no Secure), and attachable by
any cross-site request (no SameSite).
Add cookie flags with environment-aware values: Secure and
SameSite=Strict are active only when NODE_ENV=production so that
local development over plain HTTP continues to work without disabling
cookie behaviour. SameSite=lax in development still blocks third-party
POST CSRF while allowing top-level navigation redirects.
Set maxAge to 24 hours to bound the lifetime of an exposed session ID.
Add ENV NODE_ENV=production to Dockerfile.prod so the production
cookie policy activates automatically in containerised deploys.
Document NODE_ENV in .env.sample so local developers set it explicitly.
Closes #3731 parent 8d17610 commit dea96f1
3 files changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
23 | 29 | | |
24 | 30 | | |
25 | 31 | | |
| |||
0 commit comments