pub struct SessionRequest { /* private fields */ }Expand description
SessionRequest
An unsigned request with 1–16 unique sorted scopes and an optional nonzero TTL. The scope bound implies at most 1024 label bytes. Constructing or hashing this value does not grant scopes, authenticate a credential or admit its lifetime.
Implementations§
Source§impl SessionRequest
impl SessionRequest
Sourcepub fn new(
scopes: Vec<String>,
ttl_secs: Option<u64>,
) -> Result<Self, SessionRequestError>
pub fn new( scopes: Vec<String>, ttl_secs: Option<u64>, ) -> Result<Self, SessionRequestError>
Admit count, then grammar in input order, then duplicates and nonzero TTL.
Scope order is normalized. Positive TTLs, including those above the protocol ceiling, retain their exact identity until host-policy evaluation.
Sourcepub fn scopes(&self) -> &[ScopeLabel]
pub fn scopes(&self) -> &[ScopeLabel]
Borrow normalized scopes; their inclusion still needs a verified grant.
Sourcepub const fn ttl_secs(&self) -> Option<u64>
pub const fn ttl_secs(&self) -> Option<u64>
Exact submitted lifetime, preserving absence independently of host defaults.
Sourcepub fn hash(&self) -> [u8; 32]
pub fn hash(&self) -> [u8; 32]
Compute the existing V1 request identity without allocating encoded bytes.
Domain bytes have no terminator. Counts, label lengths and the optional TTL use big-endian u64; the TTL presence tag is one byte. This is a request fingerprint, never a signed credential or authorization token.
Sourcepub fn expires_at_ns(
&self,
now_ns: u64,
policy: SessionTtlPolicy,
) -> Result<u64, SessionRequestError>
pub fn expires_at_ns( &self, now_ns: u64, policy: SessionTtlPolicy, ) -> Result<u64, SessionRequestError>
Compute the requested deadline from a trusted host time and policy.
Reject over-limit TTLs and overflow. The receiver must additionally cap this deadline by login, key and enrollment deadlines; this method alone cannot establish a usable session lease.
Sourcepub fn evaluate_grants(
&self,
grants: &[DelegatedRoleGrant],
role: &AuthRole,
now_ns: u64,
policy: SessionTtlPolicy,
) -> Result<u64, SessionRequestError>
pub fn evaluate_grants( &self, grants: &[DelegatedRoleGrant], role: &AuthRole, now_ns: u64, policy: SessionTtlPolicy, ) -> Result<u64, SessionRequestError>
Check narrowing to one protected role, then calculate the requested deadline.
This is cheap request preflight, not proof verification or session admission.
Grants must be bounded, strictly ordered and unique; they are never sorted.
Other roles cannot supply missing scopes. The host owns role, time and
TTL policy. Signature, fresh-claims aggregate bounds, current authority,
replay/revocation and login/key/enrollment lease caps remain separate.