pub struct CapabilityVerifier { /* private fields */ }Expand description
Builder for verifying Hessra capability tokens with flexible configuration.
By default, capability verification only checks resource + operation.
Subject verification is optional via .with_subject().
§Example
use hessra_cap_token::{CapabilityVerifier, HessraCapability};
use hessra_token_core::{KeyPair, TokenTimeConfig};
let keypair = KeyPair::new();
let public_key = keypair.public();
let token = HessraCapability::new(
"user123".to_string(),
"resource456".to_string(),
"read".to_string(),
TokenTimeConfig::default(),
)
.issue(&keypair)?;
// Basic capability verification (no subject check)
CapabilityVerifier::new(
token.clone(),
public_key,
"resource456".to_string(),
"read".to_string(),
)
.verify()?;
// With optional subject verification
CapabilityVerifier::new(
token.clone(),
public_key,
"resource456".to_string(),
"read".to_string(),
)
.with_subject("user123".to_string())
.verify()?;Implementations§
Source§impl CapabilityVerifier
impl CapabilityVerifier
Sourcepub fn new(
token: String,
public_key: PublicKey,
resource: String,
operation: String,
) -> Self
pub fn new( token: String, public_key: PublicKey, resource: String, operation: String, ) -> Self
Creates a new capability verifier for a base64-encoded token.
§Arguments
token- The base64-encoded capability token to verifypublic_key- The public key used to verify the token signatureresource- The resource identifier to verifyoperation- The operation to verify
Sourcepub fn with_subject(self, subject: String) -> Self
pub fn with_subject(self, subject: String) -> Self
Adds an optional subject verification check.
When set, the authorizer adds a check that the minted subject matches. This is optional – pure capability verification does not require it.
§Arguments
subject- The subject to verify in the token’s right fact
Sourcepub fn with_namespace(self, namespace: String) -> Self
pub fn with_namespace(self, namespace: String) -> Self
Adds a namespace restriction to the verification.
§Arguments
namespace- The namespace to verify against (e.g., “example.com”)
Sourcepub fn with_designation(self, label: String, value: String) -> Self
pub fn with_designation(self, label: String, value: String) -> Self
Adds a designation fact to the verification.
Each designation provides a designation(label, value) fact that the
token’s designation checks will verify against.
§Arguments
label- The designation dimension (e.g., “tenant_id”)value- The specific value (e.g., “t-123”)
Auto Trait Implementations§
impl Freeze for CapabilityVerifier
impl RefUnwindSafe for CapabilityVerifier
impl Send for CapabilityVerifier
impl Sync for CapabilityVerifier
impl Unpin for CapabilityVerifier
impl UnsafeUnpin for CapabilityVerifier
impl UnwindSafe for CapabilityVerifier
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