ark::crypt::JwtDecoder

Defined in header “ark/crypt/jwt.hh”.


This class allows you to avoid reparsing the public key each time you want to validate a JWT. It will construct a verifier once, and re-use that each time.

Methods

  • JwtDecoder(const std::string & public_key)
    Constructor. Prepares internal state based on the given public key (based in as PEM-encoded).

  • ~JwtDecoder()
    Destructor.

  • void add_public_key(const std::string & key_id, const std::string & public_key)
    Adds a new public key and KID to this validator. The KID (key id) is used to determine which public key to validate your token with.

    The public key is assumed to be PEM-encoded.

  • JwtClaims validate_jwt(const std::string & token)
    This simple API accepts an encoded JWT token, validates it (throwing if the token is invalid either structurally or from a signature), and then returns a parsed structure containing metadata within that token.