pub struct PasetoV4PublicVerifier { /* private fields */ }Expand description
PASETO v4.public verifier — checks signatures with an Ed25519 public key.
The edge-safe half of v4.public: a public key can verify a token but is
physically unable to mint one. It is the only TokenVerifier in the
cheers tree that doesn’t also carry minting power (the symmetric codecs in
cheers-server are Codecs, so they do) — which is
exactly what lets an edge (e.g. a CF Worker) authenticate sessions without the
forge-any-session blast radius of holding a minting key. Pair with a
cheers_server::PasetoV4SecretMinter at the origin.
Implementations§
Source§impl PasetoV4PublicVerifier
impl PasetoV4PublicVerifier
Sourcepub fn from_public_key(
bytes: &[u8; 32],
) -> Result<PasetoV4PublicVerifier, CodecError>
pub fn from_public_key( bytes: &[u8; 32], ) -> Result<PasetoV4PublicVerifier, CodecError>
Build from a 32-byte Ed25519 public key (the V4 public-key size).
Sourcepub fn from_key(public: AsymmetricPublicKey<V4>) -> PasetoV4PublicVerifier
pub fn from_key(public: AsymmetricPublicKey<V4>) -> PasetoV4PublicVerifier
Wrap an already-parsed Ed25519 public key — e.g. the half a minter derives
from its secret key (cheers_server::PasetoV4SecretMinter::verifier).
Sourcepub fn public_key(&self) -> &AsymmetricPublicKey<V4>
pub fn public_key(&self) -> &AsymmetricPublicKey<V4>
The underlying public key, e.g. to serialize the 32 bytes for publishing to an edge.
Sourcepub fn verify_mcp_at(
&self,
token: &str,
now: i64,
expected_kid: &str,
) -> Result<McpClaims, CodecError>
pub fn verify_mcp_at( &self, token: &str, now: i64, expected_kid: &str, ) -> Result<McpClaims, CodecError>
Verify an MCP-call token signed by
cheers_server::PasetoV4SecretMinter::mint_mcp, returning the
embedded McpClaims.
Wire convention (R592-B7) — the shape kamaji-bin’s verifier,
cheers-mock, and yubaba’s minter already share: claims is the
token’s FLAT top-level JSON payload (no wrapping claim key), verified
via pasetors’ LOW-LEVEL PublicToken::verify — never the high-level
public::verify, which hard-rejects the i64 exp/iat this shape
carries.
kid is REQUIRED in the PASETO footer: an empty footer is
CodecError::MissingKid; a footer that doesn’t parse or has no
kid field is CodecError::Malformed; a kid that doesn’t match
expected_kid is CodecError::UnknownKid (this verifier holds a
single trusted (kid, public key) pair — it has no JWKS of its own,
so “does the footer’s kid match the one caller I trust” is the whole
key-selection check here; a full JWKS lookup across many kids is a
consumer’s job, e.g. kamaji-bin’s AuthVerifier).
Expiry is owned by McpClaims::is_expired_at (parity with the
session-claim path) — exp <= now is CodecError::Expired.
iss/aud are NOT checked here — that policy varies per consumer
(which issuer/audience a caller expects), so it lives at the caller
(e.g. cloud-admin’s viewer_from_claims), not in this shared
primitive.