wacht-rs
Official Rust SDK for Wacht.
Install
[]
= "0.1.0-beta.1"
= { = "1", = ["macros", "rt-multi-thread"] }
For Axum middleware support:
[]
= { = "0.1.0-beta.1", = ["axum"] }
Configuration
Environment-based setup expects:
WACHT_API_KEYWACHT_PUBLISHABLE_KEY(preferred) orWACHT_FRONTEND_HOST- optional:
WACHT_PUBLIC_SIGNING_KEY
Client Usage (instance-based)
use WachtClient;
async
You can also construct explicitly:
use ;
let config = new;
let client = new?;
Gateway Authz (API key + OAuth access token)
use GatewayPrincipalType;
let authz = client
.gateway
.verify_request_with_principal_type
.await?;
let principal = authz.resolve_principal_context;
println!;
OAuth access token:
let authz = client
.gateway
.verify_oauth_access_token_request
.await?;
Axum Middleware (axum feature)
Session JWT middleware:
use ;
use AuthLayer;
async
let app = new
.route
.layer;
Extract auth context:
use IntoResponse;
use RequireAuth;
async
License
Licensed under the Apache License, Version 2.0. See LICENSE.