mirror of
https://github.com/arun11299/cpp-jwt.git
synced 2025-05-24 05:29:18 +00:00
JWT veririfcation APIs
This commit is contained in:
parent
7a7353a9ef
commit
6f495c2c16
6 changed files with 152 additions and 14 deletions
include/jwt/test
|
@ -2,6 +2,7 @@
|
|||
#include <map>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
#include <unordered_map>
|
||||
#include "jwt/jwt.hpp"
|
||||
|
||||
|
@ -74,15 +75,18 @@ MIGkAgEBBDBeLCgapjZmvTatMHaYX3A02+0Ys3Tr8kda+E9DFnmCSiCOEig519fT
|
|||
.add_claim("where", "airport")
|
||||
.add_claim("time_str", "8:18pm 24 Nov 2017")
|
||||
.add_claim("id", 1)
|
||||
.add_claim("exp", std::chrono::system_clock::now())
|
||||
;
|
||||
|
||||
std::cout << "pem sign " << obj.signature() << std::endl;
|
||||
std::cout << "Get claim value for exp: " << obj.payload().get_claim_value("exp") << std::endl;
|
||||
sleep(4);
|
||||
auto dec_obj = jwt::decode(obj.signature(), pub_key, algorithms({"es256"}));
|
||||
std::cout << dec_obj.payload() << std::endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
basic_jwt_object_test();
|
||||
//basic_jwt_object_test();
|
||||
jwt_object_pem_test();
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue