Skip to content

Race condition on Passport Strategy when using express-session with custom store #146

@pragmaticivan

Description

@pragmaticivan

Describe the bug
Using express-session the passport strategy is trying to associate value in the session in memory.
Right after that, it performs a redirect, which doesn't wait for the session to be updated in the store. Causing sometimes to the expected value after the redirect not be available in the store yet.

The express session, for instance, calls .save automatically when the request is finished. But recommends calling .save before redirecting to a different resource. Eg.: https://github.com/expressjs/session#sessionsavecallback

To Reproduce
It's challenging to reproduce that, because the store connection needs to be experiencing some latency.
I was able to do that by using with postgres + knex as store.

Expected behaviour
A clear and concise description of what you expected to happen.

Environment:

  • openid-client version: 2.4.5
  • node version: v8.11.2

Additional context
Add any other context about the problem here.

  • the bug is happening on latest openid-client too.
  • i have searched the issues tracker on github for similar issues and couldn't find anything related.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions