Code Monkey home page Code Monkey logo

Comments (3)

pliablepixels avatar pliablepixels commented on July 21, 2024

Resolved. I was over complicating time calculation, not a problem with your library.

 .set_issued_at(jwt::date(std::chrono::system_clock::now()))          
 .set_expires_at(jwt::date(std::chrono::system_clock::now()+ std::chrono::minutes{EXPIRY}))

is the right way, it seems (as long as validation and generation happens on the same system)

from jwt-cpp.

Thalhammer avatar Thalhammer commented on July 21, 2024

Quick side note (I already looked at it before you closed it).
The time you provide must be utc.
get_time uses the local timezone I believe while the library uses std::chrono::system_time::now() by default, which is utc. This results in the token being expired at the time of creation.
You can change the clock used by specifying a custom clock struct on the creation of the verifier, however, I strongly recommend against it, as the standard specifies utc and that would break compatibility with every other system.

from jwt-cpp.

pliablepixels avatar pliablepixels commented on July 21, 2024

Thanks - I'm curious if it would be possible to post an example of the right way to get UTC time somewhere in your documents? I know its not related to your library, but I think it is a common requirement along with this application and an example that shows us how to correctly pick UTC everywhere will be very useful. Thank you.

from jwt-cpp.

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.