harbor-sdk
Add API key auth and billing to your Rust API in one line.
Harbor handles validation so your users can authenticate with keys they manage from the Harbor dashboard.
Install
[]
= "0.1"
# With Axum middleware support:
= { = "0.1", = ["axum"] }
Quick Start
Validate a key
use validate;
async
Axum middleware
use ;
use ;
async
async
The middleware reads the x-harbor-key header and validates it against the Harbor API. On success, a KeyInfo extension is inserted into the request so your handlers can access plan info, usage counts, and more.
KeyInfo fields
| Field | Type | Description |
|---|---|---|
key_id |
String |
Unique key identifier |
project_id |
String |
Your Harbor project ID |
plan |
String |
Subscription plan (e.g. "free", "pro") |
calls_this_month |
u64 |
API calls used this billing cycle |
name |
String |
Name associated with the key |
country |
Option<String> |
Country code of the key owner |
Custom validation URL
For local development with harbor-mock:
use validate_with_url;
let info = validate_with_url.await?;
Features
| Feature | Enables |
|---|---|
axum |
Axum middleware layer (axum_middleware::harbor_auth) |
full |
All optional integrations |
Links
License
MIT