Requirements
- Rust 1.70 or later
- Crates used by the SDK:
hmacsha2serdeserde_jsonureqbase64mac_addresshostname
Installation
The crate is published on crates.io/crates/authforge asauthforge.
Cargo.toml (for example 1.0 for compatible 1.x releases):
- Git (pre-release)
- Path (vendored)
branch, tag, or rev.Quick start
Config struct reference
Validate license (no session)
validate_license runs the same /auth/validate request and signature checks as login, but does not store a session on the client or start the background thread. It returns the same LoginResult on success.
Billing
- Each successful
login()orvalidate_license()costs 1 credit (one/auth/validatedebit). - The grace period is free: local session re-verification makes no network calls and consumes no credits.
- Online check-ins (if enabled) cost 1 credit per 10 successful heartbeats (billed on every 10th call).
- With online check-ins, revocations take effect on the next check-in regardless of interval; without them, at session expiry.
Methods reference
Error enum reference
Grace period and online check-ins
By default, the app runs through the grace period after activation: the SDK re-verifies the signed session locally, makes no network calls, and stops when the session expires. Opt in to online check-ins for fast revocation and concurrent-use detection:Offline license files (.authforge)
For machines that never connect to the internet, the operator mints a signed offline license file in the dashboard or Developer API (1 credit). The SDK verifies it locally with your public key and the machine HWID; no network, no check-ins, and online login is untouched. Leave app_secret empty (Default::default() already does) so the air-gapped binary does not contain the App Secret.
OfflineLicenseError enum (separate from AuthForgeError, which is unchanged), in check order: BadArmor, BadSignature, UnsupportedVersion, MalformedPayload, WrongApp, Expired, HwidMismatch, plus ReadError(String) for an unreadable path; .code() gives the cross-SDK string and on_failure receives offline_login_failed: <code>. client.verify_license_file(path_or_text) and the crate function authforge::verify_license_file(text, &opts) run the same checks without touching state. Issued files cannot be revoked remotely; they stay valid until their own expiry. create_activation_request(opts) produces the .authforge-request the operator uploads; hostname is omitted unless include_machine_name is set. See Activation requests.
Migrating from heartbeat_mode
The heartbeat_mode field and the HeartbeatMode enum are deprecated but still accepted:
heartbeat_mode: HeartbeatMode::Local: remove the field; the grace period is now the default.heartbeat_mode: HeartbeatMode::Server: useonline_heartbeat: trueinstead.
HeartbeatMode in new code.