Skip to main content

DesignationBuilder

Struct DesignationBuilder 

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

Builder for adding designation blocks to capability tokens.

Designations are standard Biscuit attenuation blocks that narrow the scope of a capability token by specifying which specific object/resource instance the token applies to. Unlike prefix restrictions (which required third-party blocks), designations use regular append-only blocks and do not require a signing key.

§Example

use hessra_cap_token::DesignationBuilder;
use hessra_token_core::PublicKey;

let attenuated = DesignationBuilder::from_base64(token, public_key)?
    .designate("tenant_id".to_string(), "t-123".to_string())
    .designate("user_id".to_string(), "u-456".to_string())
    .attenuate_base64()?;

Implementations§

Source§

impl DesignationBuilder

Source

pub fn new(token: Vec<u8>, public_key: PublicKey) -> Self

Create a new DesignationBuilder from raw token bytes.

§Arguments
  • token - The binary token data
  • public_key - The public key to verify the token
Source

pub fn from_base64( token: String, public_key: PublicKey, ) -> Result<Self, TokenError>

Create a new DesignationBuilder from a base64-encoded token string.

§Arguments
  • token - The base64-encoded token string
  • public_key - The public key to verify the token
Source

pub fn designate(self, label: String, value: String) -> Self

Add a designation (label, value) pair to narrow the token’s scope.

Each designation adds a check if designation(label, value) to the token, requiring the verifier to provide matching designation(label, value) facts.

§Arguments
  • label - The designation dimension (e.g., “tenant_id”, “user_id”, “region”)
  • value - The specific value for this dimension (e.g., “t-123”, “u-456”, “us-east-1”)
Source

pub fn attenuate(self) -> Result<Vec<u8>, TokenError>

Attenuate the token with all accumulated designations.

Returns the attenuated token as binary bytes.

Source

pub fn attenuate_base64(self) -> Result<String, TokenError>

Attenuate the token and return as a base64-encoded string.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more