Comments (8)
- I don't see why we would go to ms resolution when we only have seconds in the api/sec
- Not an issue with a decent leeway, that's what it's for
from jsonwebtoken.
@Keats thanks for the quick response!
-
I'm not proposing that we go to ms resolution. My proposed fix is in the attached PR.
-
I have not been able to identify a leeway value that fixes the following issue. Here is a drawing representing a token which is about to expire, but has not expired yet.
I would like to make the current code fail for this case since the token may expire in transit over the network.
if matches!(claims.exp, TryParse::Parsed(exp) if options.validate_exp && exp < now - options.leeway) { return Err(new_error(ErrorKind::ExpiredSignature)); }
It looks like it will succeed for all unsigned integers.
Can you suggest a leeway value that will allow me to return
ErrorKind::ExpiredSignature
when the token is about to expire? As a specific example, maybe you could suggest a value that would work when timenow=1
and timeexp=2
.
from jsonwebtoken.
It seems that what you want, rather than negative leeway which is imo a bit confusing is another option to reject tokens that are x
seconds or less from expiration?
from jsonwebtoken.
It seems that what you want, rather than negative leeway which is imo a bit confusing is another option to reject tokens that are
x
seconds or less from expiration?
@Keats yes, rejecting tokens that are x
seconds or less prior to expiration is our goal.
Configuring this as a separate setting rather than as a negative leeway value should work fine.
from jsonwebtoken.
Something like Validation::reject_tokens_expiring_in_less_than(seconds: int)
?
from jsonwebtoken.
Something like
Validation::reject_tokens_expiring_in_less_than(seconds: int)
?
Yes, that is a clear name in my opinion.
Would you like me to update the existing PR to reflect?
from jsonwebtoken.
@Keats Here is a new PR implementing Validation::reject_tokens_expiring_in_less_than
. Can you review and approve?
from jsonwebtoken.
Fix released as part of version 9.3.0; closing this issue
from jsonwebtoken.
Related Issues (20)
- Support millisecond validation on `exp` of Claims HOT 2
- Implement Brainpool ciphers HOT 1
- EncodingKey to JWK HOT 4
- Changes for ACME support HOT 2
- Urlsafe base64 hmac keys HOT 2
- Misleading function name `DecodingKey::from_ed_der`. HOT 8
- Support Extra Key/Value Pairs in the Header HOT 3
- How to customize the Header field HOT 3
- `validate_exp` should also reject tokens that contain a `exp` field but that can not be parsed
- src/pem as a separate crate? HOT 1
- Invalid signature HOT 1
- InvalidKeyFomat when using private.pem file
- Create Dummy Instances of Error HOT 2
- 大佬看下,生成的token,我定了30秒有效期,超过了30秒怎么还能解码呢, HOT 6
- Question: expected audience in validation but not encoded in the JWT seems a valid option HOT 6
- Feature Request: encryption of jsonwebtoken HOT 1
- Support algorithm: `none` HOT 1
- Validation: `required_spec_claims` HashSet should use a non-allocating value type. HOT 1
- Validation: Allow validation of custom claims HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsonwebtoken.