Hessra SDK for Rust
A secure, flexible Rust SDK for the Hessra authorization service, providing mTLS-backed token request and verification capabilities.
Features
- Secure by Design: Built-in mutual TLS (mTLS) authentication with the Hessra service
- Protocol Support: HTTP/1.1 with optional HTTP/3 (via feature flag)
- Flexible Configuration: Multiple ways to configure the client including environment variables, files, and code
- Procedural Macros: Simple attribute macros to protect functions and endpoints
Quick Start
use ;
// Create a client using the builder pattern
let client = builder
.base_url
.protocol
.mtls_cert
.mtls_key
.server_ca
.build?;
// Request a token for a protected resource
let token = client.request_token.await?;
// Verify the token later
let verification = client.verify_token.await?;
Function Protection with Macros
Protect your functions with simple attribute macros:
use request_authorization;
async
Configuration
The SDK offers multiple ways to configure the client:
- Builder Pattern: Explicitly set each option in code
- Configuration Files: Load from JSON or TOML files
- Environment Variables: Use environment variables for configuration
- Auto-discovery: Automatically find configuration in standard locations
See CONFIG.md for detailed configuration options and examples.
Installation
Add the SDK to your Cargo.toml:
[]
= "0.2"
= "0.1.0" # For procedural macros
For HTTP/3 support:
[]
= { = "0.2", = ["http3"] }
Examples
Check the examples directory for complete working examples:
- HTTP/1.1 client usage
- HTTP/3 client usage (requires the
http3feature) - Configuration loading
- Macro usage
License
This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.