-
Notifications
You must be signed in to change notification settings - Fork 726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Random Session ID? #515
Comments
Since this codebase is being used by beginners, I think we can create a script to help users fill in the |
How about we use uuid for that? |
Something like this would be sufficient i think const { v4 } = require('uuid')
app.use(
session({
secret: v4(),
cookie: { maxAge: 336 * 60 * 60 * 1000 },
...// other options
) |
i dont think we need to introduce a whole dependency for this, just use import { randomBytes } from "node:crypto";
session({
secret: process.env.SESSION_PASSWORD ?? randomBytes(32).toString("hex"),
...
}); downside to this and the uuid approach is that upon reboot, the session secret will be different, thus invalidating all existing sessions. Prefilling the alternatively, we can just update the readme to include instructions on how to generate a random secret, such as running |
But won’t generating a random one and not the value be a problem? I believe the session won’t be persisted after restart |
Simplify the setup of
SESSION_PASSWORD
by automating random secret generation. This eliminates user confusion and reduces security risks.The text was updated successfully, but these errors were encountered: