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
impl WsTicketIssuer
Sourcepub fn from_api_key(api_key: &str) -> Self
pub fn from_api_key(api_key: &str) -> Self
Derive the ticket key from the pairing api_key under the fixed label.
Sourcepub fn issuer_unpaired(salt: &[u8]) -> Self
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.
Sourcepub fn mint(&self, scope: &str, ttl_seconds: i64) -> Option<WsTicket>
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.
Sourcepub fn mint_at(
&self,
scope: &str,
ttl_seconds: i64,
now: i64,
nonce: &str,
) -> WsTicket
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.
Sourcepub fn verify(
&self,
token: &str,
expected_scope: &str,
now: i64,
) -> Result<(), WsTicketError>
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.
Sourcepub fn verify_once(
&self,
token: &str,
expected_scope: &str,
now: i64,
) -> Result<(), WsTicketError>
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.