Struct wascap::jwt::Claims

source ·
pub struct Claims<T> {
    pub expires: Option<u64>,
    pub id: String,
    pub issued_at: u64,
    pub issuer: String,
    pub subject: String,
    pub not_before: Option<u64>,
    pub metadata: Option<T>,
    /* private fields */
}
Expand description

Represents a set of RFC 7519 compliant JSON Web Token claims.

Fields§

§expires: Option<u64>

All timestamps in JWTs are stored in seconds since the epoch format as described as NumericDate in the RFC. Corresponds to the exp field in a JWT.

§id: String

Corresponds to the jti field in a JWT.

§issued_at: u64

The iat field, stored in seconds since the epoch

§issuer: String

Issuer of the token, by convention usually the public key of the account that signed the token

§subject: String

Subject of the token, usually the public key of the module corresponding to the WebAssembly file being signed

§not_before: Option<u64>

The nbf JWT field, indicates the time when the token becomes valid. If None token is valid immediately

§metadata: Option<T>

Custom jwt claims in the wascap namespace

Implementations§

source§

impl<T> Claims<T>

source

pub fn encode(&self, kp: &KeyPair) -> Result<String>

source

pub fn decode(input: &str) -> Result<Claims<T>>

source

pub fn name(&self) -> String

source§

impl Claims<Account>

source

pub fn new( name: String, issuer: String, subject: String, additional_keys: Vec<String>, ) -> Claims<Account>

Creates a new non-expiring Claims wrapper for metadata representing an account

source

pub fn with_dates( name: String, issuer: String, subject: String, not_before: Option<u64>, expires: Option<u64>, additional_keys: Vec<String>, ) -> Claims<Account>

Creates a new Claims wrapper for metadata representing an account, with optional valid before and expiration dates

source§

impl Claims<CapabilityProvider>

source

pub fn new( name: String, issuer: String, subject: String, vendor: String, rev: Option<i32>, ver: Option<String>, hashes: HashMap<String, String>, ) -> Claims<CapabilityProvider>

Creates a new non-expiring Claims wrapper for metadata representing a capability provider

source

pub fn with_provider( issuer: String, subject: String, not_before: Option<u64>, expires: Option<u64>, provider: CapabilityProvider, ) -> Claims<CapabilityProvider>

Creates a new Claims non-expiring wrapper for metadata representing a capability provider, with optional valid before and expiration dates

source

pub fn with_dates( name: String, issuer: String, subject: String, vendor: String, rev: Option<i32>, ver: Option<String>, hashes: HashMap<String, String>, not_before: Option<u64>, expires: Option<u64>, ) -> Claims<CapabilityProvider>

Creates a new Claims wrapper for metadata representing a capability provider, with optional valid before and expiration dates

source§

impl Claims<Operator>

source

pub fn new( name: String, issuer: String, subject: String, additional_keys: Vec<String>, ) -> Claims<Operator>

Creates a new non-expiring Claims wrapper for metadata representing an operator

source

pub fn with_dates( name: String, issuer: String, subject: String, not_before: Option<u64>, expires: Option<u64>, additional_keys: Vec<String>, ) -> Claims<Operator>

Creates a new Claims wrapper for metadata representing an operator, with optional valid before and expiration dates

source§

impl Claims<Cluster>

source

pub fn new( name: String, issuer: String, subject: String, additional_keys: Vec<String>, ) -> Claims<Cluster>

Creates a new non-expiring Claims wrapper for metadata representing a cluster

source

pub fn with_dates( name: String, issuer: String, subject: String, not_before: Option<u64>, expires: Option<u64>, additional_keys: Vec<String>, ) -> Claims<Cluster>

Creates a new Claims wrapper for metadata representing a cluster, with optional valid before and expiration dates

source§

impl Claims<Component>

source

pub fn new( name: String, issuer: String, subject: String, tags: Option<Vec<String>>, provider: bool, rev: Option<i32>, ver: Option<String>, call_alias: Option<String>, ) -> Self

Creates a new non-expiring Claims wrapper for metadata representing an component

source

pub fn with_dates( name: String, issuer: String, subject: String, tags: Option<Vec<String>>, not_before: Option<u64>, expires: Option<u64>, provider: bool, rev: Option<i32>, ver: Option<String>, call_alias: Option<String>, ) -> Claims<Component>

Creates a new Claims wrapper for metadata representing an component, with optional valid before and expiration dates

source§

impl Claims<Invocation>

source

pub fn new( issuer: String, subject: String, target_url: &str, origin_url: &str, hash: &str, ) -> Claims<Invocation>

Creates a new non-expiring Claims wrapper for metadata representing an invocation

source

pub fn with_dates( issuer: String, subject: String, not_before: Option<u64>, expires: Option<u64>, target_url: &str, origin_url: &str, hash: &str, ) -> Claims<Invocation>

Creates a new Claims wrapper for metadata representing an invocation, with optional valid before and expiration dates

source§

impl Claims<Host>

source

pub fn new( name: String, issuer: String, subject: String, tags: Option<HashMap<String, String>>, ) -> Self

Creates a new non-expiring Claims wrapper for metadata representing a host

source

pub fn with_dates( name: String, issuer: String, subject: String, not_before: Option<u64>, expires: Option<u64>, tags: Option<HashMap<String, String>>, ) -> Claims<Host>

Trait Implementations§

source§

impl<T: Clone> Clone for Claims<T>

source§

fn clone(&self) -> Claims<T>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for Claims<T>

source§

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

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

impl<T: Default> Default for Claims<T>

source§

fn default() -> Claims<T>

Returns the “default value” for a type. Read more
source§

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

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

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

impl<T: PartialEq> PartialEq for Claims<T>

source§

fn eq(&self, other: &Claims<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> Serialize for Claims<T>
where T: Serialize,

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<T> StructuralPartialEq for Claims<T>

Auto Trait Implementations§

§

impl<T> Freeze for Claims<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Claims<T>
where T: RefUnwindSafe,

§

impl<T> Send for Claims<T>
where T: Send,

§

impl<T> Sync for Claims<T>
where T: Sync,

§

impl<T> Unpin for Claims<T>
where T: Unpin,

§

impl<T> UnwindSafe for Claims<T>
where T: UnwindSafe,

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> 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.
source§

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

source§

fn vzip(self) -> V

source§

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