Code Monkey home page Code Monkey logo

Comments (5)

saiteja-madha avatar saiteja-madha commented on June 22, 2024

Since this codebase is being used by beginners, I think we can create a script to help users fill in the .env

from discord-js-bot.

imnaiyar avatar imnaiyar commented on June 22, 2024

How about we use uuid for that?

from discord-js-bot.

imnaiyar avatar imnaiyar commented on June 22, 2024

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
    )

from discord-js-bot.

ItzDerock avatar ItzDerock commented on June 22, 2024

i dont think we need to introduce a whole dependency for this, just use node:crypto,

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 .env works fine for all non-docker users.

alternatively, we can just update the readme to include instructions on how to generate a random secret, such as running head /dev/urandom | tr -dc A-Za-z0-9 | head -c32 or link some website.

from discord-js-bot.

saiteja-madha avatar saiteja-madha commented on June 22, 2024

But won’t generating a random one and not the value be a problem?

I believe the session won’t be persisted after restart

from discord-js-bot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.