Requirements
- C++17 or later
- libsodium: Ed25519 signature verification
- OpenSSL: SHA-256 and helpers
- libcurl: HTTPS requests
Installation
There is no central C++ package registry. Consume the official SDK from GitHub; AuthForgeCC/authforge-cpp (use a release tag under Releases).
Option A: FetchContent (CMake)
Pin a tag (for example v1.0.1) and link the authforge_sdk target:
Option B: Install prefix + find_package
Build and install the SDK, then point CMake at the prefix:
In your application:
Dependencies
Install development packages for libsodium, OpenSSL, and libcurl before configuring CMake. Examples:
- Linux (Debian/Ubuntu):
sudo apt install libsodium-dev libssl-dev libcurl4-openssl-dev
- macOS (Homebrew):
brew install libsodium openssl curl; set CMAKE_PREFIX_PATH if CMake does not find Homebrew prefixes.
- Windows: Use vcpkg for
libsodium, openssl, and curl, then pass -DCMAKE_TOOLCHAIN_FILE=.../vcpkg.cmake.
Quick start
Constructor parameters
ttlSeconds
Requested session token lifetime in seconds for /auth/validate. Pass 0 (or omit) to accept the server default of 24 hours. The server clamps to [3600, 604800] (1 hour to 7 days). The requested TTL is preserved across heartbeat refreshes so long-running apps in LOCAL mode can extend their offline window up to 7 days.
Billing
- Each successful
Login() or ValidateLicense() costs 1 credit (one /auth/validate debit).
- Heartbeats cost 1 credit per 10 successful calls (billed on every 10th heartbeat). Any heartbeat interval ≥ 1 is economically safe.
- Revocations take effect on the next heartbeat regardless of interval.
Login
Returns true on success, false otherwise. Starts background heartbeats on success.
Validate license (no heartbeat)
Same /auth/validate request and Ed25519 verification as Login, without persisting session fields on the client or starting the heartbeat thread. Does not invoke the failure callback or std::exit on error; inspect valid / errorCode instead.
Failure callback
If no callback is set (or the callback throws), the SDK calls std::exit(1).
If you don’t set an onFailure callback, the SDK terminates the process immediately via std::exit(1). Always set a callback in production.
Heartbeat modes
See Heartbeat Modes for a detailed comparison.
Full example (game)
GitHub
Full source, changelog, and issues: AuthForgeCC/authforge-cpp