question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove dynamic parameters stored in session on subsequent auth

See original GitHub issue

Hello,

I had a question about an issue that I’m experiencing with Grant right now (using grant-express 4.5.2, but it appears to function the same way in 5.x) … when I authenticate to a /connect based endpoint that has been configured to use dynamic parameters, they will be properly stored into the session. However, on subsequent auth requests to other providers, the dynamic config sticks around in the session unless manually removed. This is true even if I explicitly unset dynamic configuration using an empty array in the provider.

After looking through the code I believe it has to do with the fact that every connect function also uses init in lib/config, which in turn is using a deep-copy of the previous session and only overwriting session properties that were set to some sort of “truthy” value (or not in reserved words … e.g. “dynamic” is in there)

So my question really is … is there any way to unset these lingering session values on connect, or is it considered best practice to unset them manually on callback?

Thanks for your help! Eric

edit: Relevant code is:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
adamseacommented, Aug 26, 2020

I’m all set here - I upgraded to 4.7.0 last week and that solved the problem. Thanks again!

1reaction
adamseacommented, Aug 5, 2020

Hi @simov, thank you for the update! Yes that totally makes sense, and yes the connect URLs were coming out just fine. I did confirm that I’m in a version (4.5.2) where req.session.grant is being reused in the express handler initialization: https://github.com/simov/grant/blob/v4.5.2/lib/consumer/express.js#L27

So I’ll try updating to 4.7.0, and I’ll let you know if I have any questions! Thanks for all your work on this project too, it’s worked great for me!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Client API - NextAuth.js
The NextAuth.js client library makes it easy to interact with sessions from React applications.
Read more >
Keep up with dynamic data changes using dynamic parameters
Deploy your workbooks with dynamic parameters and never again think about manually updating your parameters with the latest data.
Read more >
Parameters | Dialogflow CX - Google Cloud
Parameters are used to capture and reference values that have been supplied by the end-user during a session. Each parameter has a name...
Read more >
How to Manage Session using Node.js and Express
Handle Session in Node.js. Manage Sessions in Express 4 and above. Perform Session validation using Node.js and ExpressJS. Working code with live demo....
Read more >
Share Session ID across Different Requests in Postman
Now we have saved the session id in Postman. All we need to do now is send this session id along with the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found