Is there a way to change an object stored in a token or to re-state the token without becoming unauthenticated
See original GitHub issueI have a sessions object for a user with the following keys: email, value, session_id, user_id and roles where roles contains a key value pair of a certain event and the user’s corresponding event {1: 'ADMIN', 2: 'ANON'}
. This is store in a JWT token in a cookie.
I want to update the roles object within session to {1: 'ADMIN', 2: 'ANON', 3: 'ADMIN'}
, and save it as a JWT in a cookie. However, I am having problems when I try to state the token again. I have also tried unstating the previous token and re-stating the new one but this is causing authentication problems too. What is considered best practice for this kind of behaviour?
Thanks
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
What Are Refresh Tokens and How to Use Them Securely
You Can Store Refresh Token In Local Storage Storing tokens in browser local storage provides persistence across page refreshes and browser ...
Read more >Replace a process level token (Windows 10) - Microsoft Learn
Describes the best practices, location, values, policy management, and security considerations for the Replace a process level token ...
Read more >How to securely store JWT tokens. - DEV Community
Now, let's explore which is the best way to store a JWT token. ... a node module that you use without knowing about...
Read more >Can You Change the Payload of a JWT Token? - YouTube
0:00 · New! Watch ads now so you can enjoy fewer interruptions. Got it.
Read more >How to Store Session Tokens in a Browser (and the impacts of ...
This is possible by storing it is a variable inside a closure (if it helps, think of it as roughly akin to a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@naazy this is fantastic and worth adding to the FAQ section of the Readme … https://github.com/dwyl/hapi-auth-jwt2#frequently-asked-questions-faq- 😉
This is how we did it:
Note we had to set the cookie to the path that the initial cookie was set on - otherwise we were ending up with 2 different token cookies for different paths!