pub struct CapabilityToken {
pub version: u8,
pub issuer: Vec<u8>,
pub audience: Option<Vec<u8>>,
pub scopes: Vec<String>,
pub expires_at: u64,
pub nonce: String,
pub proofs: Vec<ProofLink>,
pub signature: Vec<u8>,
}Expand description
A CLASP capability token.
Token format: cap_<base64url(messagepack(CapabilityToken))>
Tokens form delegation chains where each child can only narrow the parent’s scopes, never widen them.
Fields§
§version: u8Token version (currently 1)
issuer: Vec<u8>Issuer’s public key (Ed25519, 32 bytes)
audience: Option<Vec<u8>>Audience public key (None = bearer token)
scopes: Vec<String>Scopes granted (same “action:pattern” format as existing CLASP scopes)
expires_at: u64Expiration time (Unix timestamp, seconds)
nonce: StringUnique nonce to prevent replay
proofs: Vec<ProofLink>Proof chain: signatures of parent tokens in the delegation chain
signature: Vec<u8>Signature over the token payload (by issuer)
Implementations§
Source§impl CapabilityToken
impl CapabilityToken
Sourcepub fn create_root(
signing_key: &SigningKey,
scopes: Vec<String>,
expires_at: u64,
audience: Option<Vec<u8>>,
) -> Result<Self>
pub fn create_root( signing_key: &SigningKey, scopes: Vec<String>, expires_at: u64, audience: Option<Vec<u8>>, ) -> Result<Self>
Create and sign a new root capability token (no parent).
Sourcepub fn delegate(
&self,
child_signing_key: &SigningKey,
child_scopes: Vec<String>,
expires_at: u64,
audience: Option<Vec<u8>>,
) -> Result<Self>
pub fn delegate( &self, child_signing_key: &SigningKey, child_scopes: Vec<String>, expires_at: u64, audience: Option<Vec<u8>>, ) -> Result<Self>
Delegate this token to create a child with narrower scopes.
The child token can only have scopes that are a subset of this token’s scopes.
Sourcepub fn verify_signature(&self) -> Result<()>
pub fn verify_signature(&self) -> Result<()>
Verify this token’s signature
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if the token is expired
Sourcepub fn chain_depth(&self) -> usize
pub fn chain_depth(&self) -> usize
Get the delegation chain depth. Chain depth is bounded at validation time. See pentest CAP-03: Chain Depth Bypass
Trait Implementations§
Source§impl Clone for CapabilityToken
impl Clone for CapabilityToken
Source§fn clone(&self) -> CapabilityToken
fn clone(&self) -> CapabilityToken
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more