Skip to main content

ContextVerifier

Struct ContextVerifier 

Source
pub struct ContextVerifier { /* private fields */ }
Expand description

Verifier for context tokens.

Checks that the context token is valid (not expired, properly signed).

§Example

use hessra_context_token::{HessraContext, ContextVerifier};
use hessra_token_core::{KeyPair, TokenTimeConfig};

let keypair = KeyPair::new();
let public_key = keypair.public();

let token = HessraContext::new("agent:test".to_string(), TokenTimeConfig::default())
    .issue(&keypair)
    .expect("Failed to create context token");

ContextVerifier::new(token, public_key)
    .verify()
    .expect("Should verify");

Implementations§

Source§

impl ContextVerifier

Source

pub fn new(token: String, public_key: PublicKey) -> Self

Creates a new context verifier.

§Arguments
  • token - The base64-encoded context token to verify
  • public_key - The public key used to verify the token signature
Source

pub fn verify(self) -> Result<(), TokenError>

Verify the context token.

Checks that:

  • The token signature is valid
  • The token has not expired
§Returns
  • Ok(()) - If the token is valid
  • Err(TokenError) - If verification fails
Source

pub fn check_precluded_exposures( self, precluded: &[String], ) -> Result<(), TokenError>

Check that the context token does not contain any precluded exposure labels.

Verifies the token (signature + expiration) and then checks that none of the token’s exposure(...) facts match the precluded labels. Any match causes the method to return an error.

This is the authorization-grade check. For diagnostics, use extract_exposure_labels or inspect_context_token instead.

§Implementation Note

Exposure facts live in first-party appended blocks. In biscuit-auth v6, authorizer deny-policies cannot see these facts due to block scoping (Scope::Previous is a no-op for the authorizer). Instead, we verify the token cryptographically first, then inspect the verified block data for precluded labels. The authorization decision is fully encapsulated – callers never handle raw labels.

§Arguments
  • precluded - Labels that must NOT be present in the token’s exposure facts. Any match blocks the grant (OR semantics).
§Returns
  • Ok(()) - If no precluded labels are found (or precluded list is empty)
  • Err(TokenError) - If the token contains any precluded exposure label, or if the token is invalid/expired

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V