| Crates.io | hessra-token-identity |
| lib.rs | hessra-token-identity |
| version | 0.2.0 |
| created_at | 2025-08-23 16:38:02.528581+00 |
| updated_at | 2025-08-27 21:21:06.167842+00 |
| description | Hessra identity token SDK for Rust |
| homepage | |
| repository | https://github.com/Hessra-Labs/hessra-sdk.rs |
| max_upload_size | |
| id | 1807661 |
| size | 66,111 |
Identity token implementation for Hessra SDK.
This crate provides hierarchical, delegatable identity tokens using the Biscuit token format. Identity tokens serve as the authentication layer in the Hessra system, eliminating the need for mTLS certificates in most scenarios.
Identity tokens use URI-based identifiers with colon (:) delimiters for hierarchy:
urn:hessra:alice # Base identity
urn:hessra:alice:laptop # Delegated to device
urn:hessra:alice:laptop:chrome # Further delegated to application
use hessra_token_identity::{create_identity_token, verify_identity_token, add_identity_attenuation_to_token};
use biscuit_auth::{KeyPair, PublicKey};
// Create an identity token
let keypair = KeyPair::from_pem(&keypair_pem)?;
let token = create_identity_token(
"urn:hessra:alice",
keypair,
Default::default()
)?;
// Verify an identity token
let public_key = PublicKey::from_pem(&public_key_pem)?;
verify_identity_token(
&token,
public_key,
"urn:hessra:alice"
)?;
// Delegate to a sub-identity
let attenuated_token = add_identity_attenuation_to_token(
&token,
"urn:hessra:alice:laptop",
keypair,
Default::default()
)?;
When a token is attenuated (delegated), it becomes MORE restrictive:
urn:hessra:aliceurn:hessra:alice:laptopurn:hessra:alice:laptop and its sub-hierarchiesBiscuit enforces that ALL checks in ALL blocks must pass:
alice and alice:*alice:laptop and alice:laptop:*alice:laptop and alice:laptop:* are authorizedFor detailed design information, see IDENTITY_TOKEN_DESIGN.md.
Apache-2.0