Signed JWTs in the three-part JWS compact serialization.
Classes | |
| struct | JoseHeader |
| JOSE header parameters for a compact signed JWT. More... | |
| struct | Token |
| Header and claims returned by crypto::jwt::Verify. More... | |
| struct | VerificationOptions |
| Claim checks performed by crypto::jwt::Verify after signature verification. More... | |
Enumerations | |
| enum class | ExpirationPolicy { kRequired , kOptional } |
| Whether verification requires an expiration claim. More... | |
Functions | |
| JoseHeader | Parse (const formats::json::Value &value, formats::parse::To< JoseHeader >) |
| Parses the JOSE header from a JSON object. | |
| formats::json::Value | Serialize (const JoseHeader &header, formats::serialize::To< formats::json::Value >) |
| Serializes a JOSE header to a JSON object, omitting absent parameters. | |
| std::string | MakeToken (const formats::json::Value &payload, const crypto::Signer &signer) |
| Signs the supplied claims with typ: JWT and the signer's algorithm. Checks registered claim types before signing. | |
| std::string | MakeToken (std::string_view json_payload, const crypto::Signer &signer) |
| Creates a compact token from the exact bytes of a serialized JSON payload. The header contains typ: JWT followed by the signer's alg. Any crypto::Signer is accepted, including crypto::SignerNone for unsigned tokens. The caller is responsible for validating registered claims. | |
| std::string | MakeToken (std::string_view json_payload, const crypto::Signer &signer, std::string_view key_id) |
| JoseHeader | UnverifiedParseJoseHeader (std::string_view token) |
| Reads the unverified JOSE header from a compact JWT for key selection. Checks the three-part structure and decodes only the header. The returned algorithm may be unknown. Pass the original token to crypto::jwt::Verify to check the algorithm, signature, and claims. | |
| Token | Verify (std::string_view token, const crypto::Verifier &verifier, const VerificationOptions &options={}) |
| Verifies a JWT with the application's trusted key and algorithm, then validates its registered claims. | |
|
strong |
| std::string crypto::jwt::MakeToken | ( | const formats::json::Value & | payload, |
| const crypto::Signer & | signer ) |
Signs the supplied claims with typ: JWT and the signer's algorithm. Checks registered claim types before signing.
| crypto::SignError | for an unsupported algorithm, invalid claims, or a signing failure. |
| std::string crypto::jwt::MakeToken | ( | std::string_view | json_payload, |
| const crypto::Signer & | signer ) |
Creates a compact token from the exact bytes of a serialized JSON payload. The header contains typ: JWT followed by the signer's alg. Any crypto::Signer is accepted, including crypto::SignerNone for unsigned tokens. The caller is responsible for validating registered claims.
| std::string crypto::jwt::MakeToken | ( | std::string_view | json_payload, |
| const crypto::Signer & | signer, | ||
| std::string_view | key_id ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Appends kid to the header, including when key_id is empty.
| JoseHeader crypto::jwt::UnverifiedParseJoseHeader | ( | std::string_view | token | ) |
Reads the unverified JOSE header from a compact JWT for key selection. Checks the three-part structure and decodes only the header. The returned algorithm may be unknown. Pass the original token to crypto::jwt::Verify to check the algorithm, signature, and claims.
| crypto::VerificationError | for malformed compact structure, invalid header parameters, unsupported critical or unencoded-payload extensions, or a nested JWT content type. |
| Token crypto::jwt::Verify | ( | std::string_view | token, |
| const crypto::Verifier & | verifier, | ||
| const VerificationOptions & | options = {} ) |
Verifies a JWT with the application's trusted key and algorithm, then validates its registered claims.
| crypto::VerificationError | if parsing, signature verification, or claim checks fail. |
| std::invalid_argument | if options contains a negative leeway. |