Skip to content
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

Fix premature redirect when used with express-session #680

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zypA13510
Copy link

Are you implementing a new feature?

I'm not sure if you will call this "a new feature", it will solve a lot of issues involving express-session not saving the session in time before redirects happen, by calling req.session.save().

Is this a security patch?

No

Detail

By calling req.session.save() before res.redirect(), it ensures the session is properly stored in the session store, avoiding issues like #306, #401, #477, #482 (and possibly #254, #314, #521). To ensure compatibility, the code will check req.session.save && typeof req.session.save == 'function' before calling req.session.save(). Reference: expressjs/session#74

Note

As I only tested this with express, express-session and a specific session store for express-session, I'm not sure if this would cause issue with Connect or other middlewares. A more thorough test is probably required.

Checklist

  • I have read the CONTRIBUTING guidelines.
  • I have added test cases which verify the correct operation of this feature or patch.
  • I have added documentation pertaining to this feature or patch.
  • The automated test suite ($ make test) executes successfully.
  • The automated code linting ($ make lint) executes successfully.

@coveralls
Copy link

coveralls commented May 18, 2018

Coverage Status

Coverage decreased (-0.5%) to 98.329% when pulling 1db59e7 on zypA13510:master into 2327a36 on jaredhanson:master.

@mckenzieja
Copy link

Is Passport not being maintained anymore?

@rwky
Copy link

rwky commented Jul 7, 2018

@zypA13510 would you like to create this PR against https://github.com/passport-next/passport and I'll take a look.

@zypA13510
Copy link
Author

@jaredhanson Since this is neither closed nor commented, unlike #686, I take it that you would consider this if the checklist items are finished?

@rwky
Copy link

rwky commented Jul 24, 2018

@zypA13510 this isn't maintained anymore, if you make a PR against the fork I'll look at it.

@zypA13510
Copy link
Author

@rwky PR created. But you know, I'm reluctant to do this because it is a middleware I used that use passport. I'm not using passport directly. So even if you are able to fix this in your fork, the middleware has to switch the dependency to your fork for this to work (probably never happen).

@rwky
Copy link

rwky commented Jul 26, 2018

@zypA13510 is the middleware on github?

@zypA13510
Copy link
Author

@rwky
Copy link

rwky commented Jul 26, 2018

@zypA13510 I created a PR okta/okta-oidc-js#250 in that repo which switches to the fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants