turnkey_jwt_verify
Core verification utils for JWTs that Turnkey mints. This crate has the generic core verification logic, but does not include support for any specific profiles. Concrete profile support can be found in turnkey_jwt_profiles. Most users are not expected to use this crate directly and should instead use turnkey_jwt_profiles.
Example
use Deserialize;
use ;
VerifiedJws::claims then parses the payload. The payload must be a JSON
object with no nulls and no repeated member names at any depth. A payload
that is not JSON is Malformed. A payload that is not a strict object or
does not match the struct is BadClaim.
Defining a claims struct
claims checks only the top level and the rules above. The struct decides
the rest, so define it as follows:
- Derive
Deserializewith#[serde(deny_unknown_fields)]. Without it, serde ignores claims the profile does not define. - Put
#[serde(deny_unknown_fields)]on every nested struct too. - Put
#[serde(deserialize_with = "turnkey_jwt_verify::object")]on each member whose type is a struct. Serde also accepts a struct as a JSON array of its fields in order, andobjectrejects that form. AVec<Inner>orOption<Inner>member is not covered: eachInnerstill accepts the array form. - Use
Option<_>with#[serde(default)]for an optional claim.
use Deserialize;
use object;