Add set_expires_in and set_issued_now methods (#322)

* Add set_expires_in and set_issued_now methods

* Add a Clock type parameter for builder

* set_expires_in method sets exp from the current moment

* Update default traits with the new builder interface

* Add VerifyTokenExpirationInValid for all traits

* Use the new methods in examples

* Add create method to specify the clock type

* Use JWT_CLAIM_EXPLICIT for explicit constructors

* Fix builder factory method in mustache file

* fixup whitespace

* default template was missing a few args

* fix whitespace

* linter

---------

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
This commit is contained in:
Ilya Andreev
2023-12-30 18:29:51 +03:00
committed by GitHub
parent 953aab6fe4
commit a1ac7a0735
17 changed files with 143 additions and 28 deletions

View File

@@ -35,8 +35,8 @@ rK0/Ikt5ybqUzKCMJZg2VKGTxg==
.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, "", ""));