Generate 2 tokens with different exp time
See original GitHub issueI’m trying to generate 2 tokens: authorization token and refresh token. These tokens usually have different validity time. I can make a PR to add the options object in jwtService.sign, jwtService.verify, in order to override the existing JWT_MODULE_OPTIONS if another options are provided when calling the methods. This way we can generate an authorization token for 1 minute and a refresh token for let’s say 8h.
I’m submitting a…
[ ] Regression
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
In the current implementation you can generate tokens with the same validity time. Authorization token and refresh token would have the same validity time and this defies the whole purpose of this auth mechanism.
Expected behavior
Being able to generate tokens with different validity time.
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
Generate tokens with different validity time.
Environment
Nest version: 5.2.1
For Tooling issues:
- Node version: 10.11.0
- Platform: Mac
Others:
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Token Best Practices - Auth0
Lists best practices when using tokens in authentication and authorization.
Read more >How To Use JSON Web Tokens (JWTs) in Express.js
The token expire time. The token secret is a long random string used to encrypt and decrypt the data. To generate this secret,...
Read more >Specify the maximum token expiration time—Portal for ArcGIS
Specify the maximum token expiration time · ArcGIS token—120 minutes · OAuth access token, when created with the Implicit or Client Credentials grant...
Read more >Changing token expiration (time-to-live) - Apache Usergrid
By default, all tokens have a system-defined time-to-live of 7 days (604800 seconds). Note that Token ttl is specified in milliseconds, but when...
Read more >Generating Tokens for API Requests - Apple Developer
Create JSON Web Tokens signed with your private key to authorize API requests. ... exp - Expiration Time. The token's expiration time in...
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
hello what about two different secret keys? secret key for access token and different secret key for refresh token?
A simple implementation can help you on this without module support:
Install
jsonwebtoken
package and its type definition:Implement the refresh token like these:
Hope this help!