GithubHelp home page GithubHelp logo

Comments (8)

Keats avatar Keats commented on June 12, 2024
  1. I don't see why we would go to ms resolution when we only have seconds in the api/sec
  2. Not an issue with a decent leeway, that's what it's for

from jsonwebtoken.

ploftness-tesla avatar ploftness-tesla commented on June 12, 2024

@Keats thanks for the quick response!

  1. I'm not proposing that we go to ms resolution. My proposed fix is in the attached PR.

  2. 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.

    positive-leeway (1)

    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.

    positive-leeway-series

    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 time now=1 and time exp=2.

from jsonwebtoken.

Keats avatar Keats commented on June 12, 2024

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.

ploftness-tesla avatar ploftness-tesla commented on June 12, 2024

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.

Keats avatar Keats commented on June 12, 2024

Something like Validation::reject_tokens_expiring_in_less_than(seconds: int)?

from jsonwebtoken.

ploftness-tesla avatar ploftness-tesla commented on June 12, 2024

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.

ploftness-tesla avatar ploftness-tesla commented on June 12, 2024

@Keats Here is a new PR implementing Validation::reject_tokens_expiring_in_less_than. Can you review and approve?

from jsonwebtoken.

ploftness-tesla avatar ploftness-tesla commented on June 12, 2024

Fix released as part of version 9.3.0; closing this issue

from jsonwebtoken.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.