Skip to main content

UserDelegation

Struct UserDelegation 

Source
#[non_exhaustive]
pub struct UserDelegation { pub bound_to: PrincipalId, pub camp_id: String, pub issued_at: i64, pub expires_at: i64, pub user_signing_key: [u8; 32], pub signature: [u8; 64], }
Expand description

A short-lived authorization signed by a user U that lets cheers bind a camp principal to U at provision time.

The signed payload is the canonical byte serialization of every field except signature itself (see signing_payload). Construct via UserDelegation::new — the constructor enforces the invariants the authority would otherwise reject downstream. Deserialization runs those same checks via [RawUserDelegation], so a wire payload can’t bypass them.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§bound_to: PrincipalId

The user authorising the delegation. MUST have kind = User.

§camp_id: String

Camp identifier (the bare half of the to-be-minted camp:<id>). Non-empty.

§issued_at: i64

Unix-second timestamp the user signed at.

§expires_at: i64

Unix-second timestamp the delegation stops being acceptable.

§user_signing_key: [u8; 32]

Ed25519 public key the signature must verify under (32 bytes). Wire form: base64url-no-pad string.

§signature: [u8; 64]

Ed25519 signature over signing_payload (64 bytes). Wire form: base64url-no-pad string.

Implementations§

Source§

impl UserDelegation

Source

pub fn new( bound_to: PrincipalId, camp_id: impl Into<String>, issued_at: i64, expires_at: i64, user_signing_key: [u8; 32], signature: [u8; 64], ) -> Result<Self, DelegationError>

Construct + validate. Rejects a non-user bound_to, an empty camp_id, or an expires_at not strictly after issued_at.

Source

pub fn is_expired_at(&self, now: i64) -> bool

true iff expires_at <= now — mirrors McpClaims::is_expired_at.

Source

pub fn signing_payload(&self) -> Vec<u8>

Canonical bytes the user signed.

Stable across runs: a fixed-ordered struct of every field except the signature itself, serialized through serde_json (which preserves struct field order). Producers (the yah-side W122 signing flow) and verifiers (cheers-server) MUST agree on this format byte-for-byte; any change is a wire-contract change.

Trait Implementations§

Source§

impl Clone for UserDelegation

Source§

fn clone(&self) -> UserDelegation

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UserDelegation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for UserDelegation

Source§

fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for UserDelegation

Source§

impl PartialEq for UserDelegation

Source§

fn eq(&self, other: &UserDelegation) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for UserDelegation

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for UserDelegation

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.