Struct rjwt::Actor

source ·
pub struct Actor<A> { /* private fields */ }
Expand description

An actor with an identifier of type T and an ECDSA keypair used to sign tokens.

IMPORTANT NOTE: for security reasons, although Actor implements Clone, its secret key will NOT be cloned. For example:

let actor = Actor::<String>::new("id".to_string()); // this has a new secret key
let cloned = actor.clone(); // this does NOT have a secret key, only a public key

Implementations§

source§

impl<A> Actor<A>

source

pub fn new(id: A) -> Self

Return an Actor with a newly-generated keypair.

source

pub fn with_keypair( id: A, public_key: &[u8], secret: &[u8] ) -> Result<Self, Error>

Return an Actor with the given keypair, or an error if the keypair is invalid.

source

pub fn with_public_key(id: A, public_key: &[u8]) -> Result<Self, Error>

Return an Actor with the given public key, or an error if the key is invalid.

source

pub fn id(&self) -> &A

Borrow the identifier of this actor.

source

pub fn public_key(&self) -> &VerifyingKey

Borrow the public key of this actor, which a client can use to verify a signature.

source

pub fn sign_token_inner<H, C>( &self, token: &Token<H, A, C> ) -> Result<String, Error>
where H: Serialize, A: Serialize, C: Serialize,

source

pub fn sign_token<H, C>( &self, token: Token<H, A, C> ) -> Result<SignedToken<H, A, C>, Error>
where H: Serialize, A: Serialize, C: Serialize,

Encode and sign the given token data.

source

pub fn consume_and_sign<H, C>( &self, token: SignedToken<H, A, C>, host_id: H, claims: C, now: SystemTime ) -> Result<SignedToken<H, A, C>, Error>
where H: Serialize + Clone, A: Serialize + Clone, C: Serialize + Clone,

Encode and sign a new token which inherits the claims of the given token and includes the new claims.

Trait Implementations§

source§

impl<A: Clone> Clone for Actor<A>

source§

fn clone(&self) -> Self

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

Auto Trait Implementations§

§

impl<A> RefUnwindSafe for Actor<A>
where A: RefUnwindSafe,

§

impl<A> Send for Actor<A>
where A: Send,

§

impl<A> Sync for Actor<A>
where A: Sync,

§

impl<A> Unpin for Actor<A>
where A: Unpin,

§

impl<A> UnwindSafe for Actor<A>
where A: 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> 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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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

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

§

fn vzip(self) -> V