Skip to main content

WsTicketIssuer

Struct WsTicketIssuer 

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

Mints and verifies self-contained WS tickets, keyed by a pairing-derived secret. Build one with WsTicketIssuer::from_api_key from the same pairing.json api_key both daemons read.

Implementations§

Source§

impl WsTicketIssuer

Source

pub fn from_api_key(api_key: &str) -> Self

Derive the ticket key from the pairing api_key under the fixed label.

Source

pub fn issuer_unpaired(salt: &[u8]) -> Self

The issuer for an UNPAIRED node: the ticket key is derived from the dashboard-PIN salt under its own label. A ticket from it proves the holder unlocked the PIN on this node since the PIN was last set (a reset rotates the salt and revokes every such ticket), which is what an operator-LAN caller must show to open a stream while the node is unpaired. It can never verify as a paired ticket, nor the reverse.

Source

pub fn mint(&self, scope: &str, ttl_seconds: i64) -> Option<WsTicket>

Mint a ticket for scope valid for ttl_seconds, using the wall clock and a fresh random nonce. None only when the system cannot supply randomness.

Source

pub fn mint_at( &self, scope: &str, ttl_seconds: i64, now: i64, nonce: &str, ) -> WsTicket

Deterministic mint core (explicit clock and nonce) for tests and cross-impl vectors.

Source

pub fn verify( &self, token: &str, expected_scope: &str, now: i64, ) -> Result<(), WsTicketError>

Verify a ticket string: HMAC authenticity first, then scope, then expiry. now is unix seconds. Does not spend the ticket; a WebSocket handshake uses Self::verify_once.

Source

pub fn verify_once( &self, token: &str, expected_scope: &str, now: i64, ) -> Result<(), WsTicketError>

Verify a ticket presented on a WebSocket handshake and spend it, so the same ticket cannot open a second socket.

Trait Implementations§

Source§

impl Clone for WsTicketIssuer

Source§

fn clone(&self) -> Self

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

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> 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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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