bunnyapp-license-rust
License validation SDK for Bunny subscriptions.
Usage
use ;
async
A single call to validate_license() automatically selects the correct mode based on which environment variable is set.
Environment variables
| Variable | Required | Description |
|---|---|---|
BUNNY_HOST |
Online mode only | Base URL of the Bunny API, e.g. https://auth.bunny.com |
BUNNY_LICENSE_KEY |
Online mode | License key sent to the API for validation |
BUNNY_OFFLINE_LICENSE_KEY |
Offline mode | Pre-issued JWT used in air-gapped environments |
BUNNY_LICENSE_KEY takes precedence. If neither is set, validate_license() returns LicenseError::NoLicenseKeySet.
Modes
Online mode
Set BUNNY_LICENSE_KEY and BUNNY_HOST. The SDK will:
- POST to
{BUNNY_HOST}/api/license/validatewith the key as a Bearer token. - Extract the JWT from the
{ "token": "..." }response. - Fetch
{BUNNY_HOST}/api/.well-known/jwks.jsonand verify the JWT signature. - Return the verified
LicenseClaims.
Offline / air-gapped mode
Set BUNNY_OFFLINE_LICENSE_KEY to the pre-issued JWT. The SDK will:
- Verify the JWT signature against the keys bundled inside the SDK.
- Return the verified
LicenseClaims.
Only asymmetric algorithms (RS*, ES*, PS*) are accepted; symmetric (HS*) algorithms are rejected.
Claims
Testing
Run the full test suite:
Useful variants:
The test suite covers both modes end-to-end without requiring a live Bunny API. Online tests use a wiremock mock server; offline tests use a separate test JWKS (src/keys/test_offline_jwks.json) that is swapped in at compile time via #[cfg(test)] so the production bundled keys are never touched by tests.
Rotating offline keys
When Bunny rotates its signing keys, update the bundled JWKS and cut a new SDK release:
Then rebuild and publish (see Publishing below).
Publishing
Bump the version in Cargo.toml, then:
Tag the release after publishing:
The crate is published as bunnyapp-license.