Giter Club home page Giter Club logo

Comments (4)

Tirke avatar Tirke commented on August 11, 2024 1

@simoneb I still have this problem, but I realise that I haven't provided you with a minimal reproduction, so I'm opening a new issue with a minimal reproduction to show that the problem does exist.

from fastify-secure-session.

mcollina avatar mcollina commented on August 11, 2024

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

from fastify-secure-session.

wilkmaia avatar wilkmaia commented on August 11, 2024

@Tirke I've tried with the following snippet and couldn't reproduce the issue you mentioned. Could you maybe show me where I got it wrong?

Environment

Windows host - NodeJS v16.10.0

Snippet

const Fastify = require('fastify')
const secureSession = require('@fastify/secure-session')

const run = async () => {
  const app = Fastify()

  await app.register(secureSession, {
    secret: 'averylogphrasebiggerthanthirtytwochars',
    salt: 'mq9hDxBVDbspDR6n',
  })

  app.post('/', (request, reply) => {
    request.session.set('data', request.body)
    reply.send('session set')
  })

  app.get('/', (request, reply) => {
    const data = request.session.get('data')
    if (!data) {
      reply.code(404).send()
      return
    }
    reply.send(data)
  })

  app.get('/all', (request, reply) => {
    // get all data from session
    const data = request.session.data()
    if (!data) {
      reply.code(404).send()
      return
    }
    reply.send(data)
  })

  app.listen({ port: 3000 })
}

run()

package.json

{
  "dependencies": {
    "@fastify/secure-session": "5.3.0",
    "fastify": "4.9.2"
  }
}

For the sake of completeness I've also run the same snippet using the current versions (NodeJS v18.14.0, fastify v4.12.0, @fastify/secure-session v6.0.0) and got the same result.

There's the remote possibility of it being an OS-related issue but, for the reason I expain below, I find it unlikely at this point.


Also, by taking a look at the code of the plugins I couldn't find any piece of code setting the signed flag in the options object. With that flag not being set the code shouldn't reach the line where signer is undefined. With the default cookie settings (i.e. not passing cookie in the plugin's options) an empty object is passed to setCookie. The signed option should always be undefined in that scenario.

Maybe I'm missing something but I'm not being able to either identify the issue or reproduce it in order to work on a fix.

from fastify-secure-session.

simoneb avatar simoneb commented on August 11, 2024

I can confirm this is also working for me, with an independent repro. @Tirke thanks for the analysis nonetheless, feel free to reopen this issue if for any reason you still cannot workaround the problem you reported.

from fastify-secure-session.

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.