Skip to main content

PasetoV4PublicVerifier

Struct PasetoV4PublicVerifier 

Source
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

Source

pub fn from_public_key( bytes: &[u8; 32], ) -> Result<PasetoV4PublicVerifier, CodecError>

Build from a 32-byte Ed25519 public key (the V4 public-key size).

Source

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).

Source

pub fn public_key(&self) -> &AsymmetricPublicKey<V4>

The underlying public key, e.g. to serialize the 32 bytes for publishing to an edge.

Source

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.

Trait Implementations§

Source§

impl TokenVerifier for PasetoV4PublicVerifier

Source§

fn verify_at(&self, token: &str, now: i64) -> Result<Claims, CodecError>

Verify a token against now (unix seconds). Reject if expires_at <= now.
Source§

fn verify(&self, token: &str) -> Result<Claims, CodecError>

Convenience wrapper using the system clock.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.