Add set_expires_in and set_issued_now methods by bugdea1er · Pull Request #322 · Thalhammer/jwt-cpp
I think these are good QOL improvements. Just all of the examples
auto token = jwt::create()
.set_issuer("auth0")
.set_type("JWT")
.set_id("rsa-create-example")
- .set_issued_at(std::chrono::system_clock::now())
- .set_expires_at(std::chrono::system_clock::now() + std::chrono::seconds{36000})
+ .set_issued_now()
+ .set_expires_in(std::chrono::seconds{36000})
.set_payload_claim("sample", jwt::claim(std::string{"test"}))
.sign(jwt::algorithm::rs256("", rsa_priv_key, "", ""));I would love to bring the verifier and builder closer in API design by making them use the default_clock and this way under the hood both of them can have a clock::now() to help them.
I think it makes sense the build could do the same as
| verify_ops::verify_context<json_traits> ctx{clock.now(), jwt, default_leeway}; |
WDYT?