Custom Signature Algorithms
The libraries design is open so you can implement your own algorithms, see existing implementations for ideas.
struct your_algorithm{
std::string sign(const std::string& , std::error_code& ec) const {
ec.clear();
return {};
}
void verify(
const std::string& ,
const std::string& signature, std::error_code& ec)
const {
ec.clear();
if (!signature.empty()) { ec = error::signature_verification_error::invalid_signature; }
}
std::string name() const { return "your_algorithm"; }
};
verifier< Clock, json_traits > verify(Clock c)
Definition jwt.h:4109
Then everything else is the same, just pass in your implementation such as:
.set_id("custom-algo-example")
.set_issued_now()
.set_expires_in(std::chrono::seconds{36000})
.set_payload_claim(
"sample",
jwt::claim(std::string{
"test"}))
.sign(your_algorithm{});
a class to store a generic JSON value as claim
Definition jwt.h:2549
builder< default_clock, traits::boost_json > create()
Definition defaults.h:31