ricardosaracino / nestjs-sp

OpenAM Nest JS Samlv2 Service Provider
10 stars 2 forks source link

What about session + mongoose ? #9

Closed mkubdev closed 3 years ago

mkubdev commented 3 years ago

Hello ricardo, thanks a lot for this repos. It really helped to build a nestjs SP app to auth an SAMLv2 authentication. First step with the ADFS IDP was successfull ! I can get back the profile with adfs's user informations.

But i have a question, do you already manage to save a session into mongodb with mongoose instead of FileStorage ? I'm struggling to find a good documentation about this niche.

Have a good day, thanks again!

mkubdev commented 3 years ago

Again, solved myself 👍🏻 ! To save a session on your MongoDB Database, you could use connect-mongo :

 app.use(session({

    // store: new FileStore({ path: './sessions' }), 

    store: MongoStore.create({ mongoUrl: process.env.MONGO_URI_LOCAL }),
    secret: 'secret',
    resave: true,
    saveUninitialized: false,
    cookie: {
      maxAge: 2.628e+9, // 1 month
      // sameSite: false,
      // httpOnly: false,
      // secure: false,
    },
  }));