| Crates.io | armature-jwt |
| lib.rs | armature-jwt |
| version | 0.1.1 |
| created_at | 2025-12-26 23:12:04.204254+00 |
| updated_at | 2025-12-29 01:11:59.070021+00 |
| description | JWT token handling for Armature authentication |
| homepage | https://pegasusheavy.github.io/armature |
| repository | https://github.com/pegasusheavy/armature |
| max_upload_size | |
| id | 2006392 |
| size | 107,353 |
JWT authentication and authorization for the Armature framework.
[dependencies]
armature-jwt = "0.1"
use armature_jwt::{JwtManager, JwtConfig, Claims};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create JWT manager
let config = JwtConfig::new("your-secret-key")
.expiration(Duration::from_secs(3600));
let jwt = JwtManager::new(config);
// Create a token
let claims = Claims::new()
.subject("user123")
.claim("role", "admin");
let token = jwt.sign(&claims)?;
// Verify a token
let verified = jwt.verify(&token)?;
println!("User: {}", verified.sub.unwrap());
Ok(())
}
// Generate token pair (access + refresh)
let (access, refresh) = jwt.generate_pair(&claims)?;
// Refresh the access token
let new_access = jwt.refresh(&refresh)?;
MIT OR Apache-2.0