Expand description
Astrid Capabilities - Cryptographically signed authorization tokens.
This crate provides:
- Capability tokens with ed25519 signatures
- Resource patterns with glob matching
- Session and persistent token storage
- Token validation and authorization checking
§Security Model
Every capability token is:
- Signed by the runtime’s ed25519 key
- Linked to the approval audit entry that created it
- Time-bounded (optional expiration)
- Scoped (session or persistent)
§Example
use astrid_capabilities::{
CapabilityToken, CapabilityStore, ResourcePattern, TokenScope, AuditEntryId,
};
use astrid_core::Permission;
use astrid_crypto::KeyPair;
// Create a capability store
let store = CapabilityStore::in_memory();
// Runtime key for signing
let runtime_key = KeyPair::generate();
// Create a capability token
let token = CapabilityToken::create(
ResourcePattern::new("mcp://filesystem:*").unwrap(),
vec![Permission::Invoke],
TokenScope::Session,
runtime_key.key_id(),
AuditEntryId::new(),
&runtime_key,
None,
);
// Add to store
store.add(token).unwrap();
// Check capability
assert!(store.has_capability("mcp://filesystem:read_file", Permission::Invoke));Modules§
- prelude
- Prelude module - commonly used types for convenient import.
Structs§
- Audit
Entry Id - Unique identifier for an audit entry (used for linking).
- Capability
Store - Capability store with both session and persistent storage.
- Capability
Token - A capability token granting permissions for a resource.
- Capability
Validator - Capability validator for checking authorization.
- DirHandle
- A cryptographic handle representing an open directory within the VFS. This acts as a capability token preventing the guest from forging arbitrary paths.
- File
Handle - A cryptographic handle representing an open file within the VFS.
- Resource
Pattern - A pattern that matches resources.
Enums§
- Authorization
Result - Authorization result after validation.
- Capability
Error - Errors that can occur with capability tokens.
- Token
Scope - Token scope - how long it lasts.
Type Aliases§
- Capability
Result - Result type for capability operations.