pub struct HessraCapability { /* private fields */ }Expand description
Builder for creating Hessra capability tokens with flexible configuration.
Capability tokens grant access to a resource+operation. The subject field is retained for auditing, but the token no longer requires the verifier to prove who is presenting it. Presenting the capability IS the authorization.
§Example
use hessra_cap_token::HessraCapability;
use hessra_token_core::{KeyPair, TokenTimeConfig};
let keypair = KeyPair::new();
// Basic capability token
let token = HessraCapability::new(
"alice".to_string(),
"resource1".to_string(),
"read".to_string(),
TokenTimeConfig::default()
)
.issue(&keypair)
.expect("Failed to create token");Implementations§
Source§impl HessraCapability
impl HessraCapability
Sourcepub fn new(
subject: String,
resource: String,
operation: String,
time_config: TokenTimeConfig,
) -> Self
pub fn new( subject: String, resource: String, operation: String, time_config: TokenTimeConfig, ) -> Self
Creates a new capability token builder.
§Arguments
subject- The subject (user) identifier (retained for auditing)resource- The resource identifier to grant access tooperation- The operation to grant access totime_config- Time configuration for token validity
Sourcepub fn namespace_restricted(self, namespace: String) -> Self
pub fn namespace_restricted(self, namespace: String) -> Self
Restricts the capability to a specific namespace.
Adds a namespace restriction check to the authority block:
check if namespace({namespace})
§Arguments
namespace- The namespace to restrict to (e.g., “myapp.hessra.dev”)
Auto Trait Implementations§
impl Freeze for HessraCapability
impl RefUnwindSafe for HessraCapability
impl Send for HessraCapability
impl Sync for HessraCapability
impl Unpin for HessraCapability
impl UnsafeUnpin for HessraCapability
impl UnwindSafe for HessraCapability
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more