fastapi-license
Enterprise hardware-bound license system for FastAPI applications.
Distribusi binary terobfuskasi via PyArmor v8+ BCC mode, dengan CLI berbasis Click + Rich dan integrasi FastAPI Lifespan & Middleware.
Instalasi
pip install fastapi-license
Alur Kerja
1. Client: Ambil Hardware Fingerprint (Server Klien)
fastapi-license probe --output fingerprint.json
2. Developer: Generate Lisensi
fastapi-license gen \
--fingerprint fingerprint.json \
--expiry 2027-12-31 \
--features "analytics,pdf_export,billing" \
--private-key private.pem \
--output license.lic
3. Developer: Build & Obfuskasi Kode FastAPI
fastapi-license build --src ./my_app --dist ./dist_protected --bcc
4. Admin: Inspeksi Lisensi
fastapi-license inspect --license license.lic --public-key public.pem
Integrasi FastAPI
from contextlib import asynccontextmanager
from fastapi import FastAPI, Depends
from fastapi_license import LicenseManager, LicenseGuardMiddleware, require_feature
license_manager = LicenseManager(
license_path="license.lic",
public_key_path="public.pem"
)
@asynccontextmanager
async def lifespan(app: FastAPI):
license_manager.verify_on_startup()
yield
app = FastAPI(title="Protected API", lifespan=lifespan)
app.add_middleware(LicenseGuardMiddleware, manager=license_manager)
@app.get("/api/analytics", dependencies=[Depends(require_feature("analytics"))])
async def analytics():
return {"data": "Analytics stream"}
Generate Keypair
from fastapi_license.core.crypto import CryptoEngine
engine = CryptoEngine()
private_pem, public_pem = engine.generate_keypair(algorithm="ed25519")
with open("private.pem", "wb") as f:
f.write(private_pem)
with open("public.pem", "wb") as f:
f.write(public_pem)
Security Architecture
- Hardware Binding: CPU ID + Motherboard UUID + Root Disk Serial + Primary MAC → SHA-256
- Cryptography: Ed25519 (default) / RSA-4096 asymmetric signature
- Obfuscation: PyArmor v8+ BCC Mode → native C binary (
.so/.pyd) - Fail-Closed: Semua error lisensi menyebabkan
sys.exit(1)sebelum server bind port - Clock Anti-Tamper: Monotonic clock + heartbeat timestamp comparison
Exception Hierarchy
| Exception | Trigger |
|---|---|
LicenseNotFoundError |
File license.lic tidak ditemukan |
TamperDetectedError |
Signature cryptographic tidak valid |
HardwareMismatchError |
Hardware ID server tidak cocok |
LicenseExpiredError |
Tanggal kedaluwarsa terlewat |
ClockTamperError |
Manipulasi waktu sistem terdeteksi |
Metadata
Release files for fastapi-license 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastapi_license-1.0.0.tar.gz | 36.7 kB | Without provenance | Details for fastapi_license-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastapi_license-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for fastapi_license-1.0.0-py3-none-any.whl |
Total release size: 62.1 kB
Release files / fastapi_license-1.0.0.tar.gz
| Download URL | fastapi_license-1.0.0.tar.gz |
|---|---|
| Size | 36.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d0002d7049afbdcf1ae853024b02a08df96f5fcd376e6572cfac1b2d3df27fd
|
|
BLAKE2b-256 checksum How to use checksums |
4f47c4e0207e37cf28539bd3137f1713bf259316fcba314f09fe8ea6cfa769ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Release files / fastapi_license-1.0.0-py3-none-any.whl
| Download URL | fastapi_license-1.0.0-py3-none-any.whl |
|---|---|
| Size | 25.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80a6f2fb8572ee7eb01ce7c6f1cd2f68cb508d2f8ff21b28765c60779aacea55
|
|
BLAKE2b-256 checksum How to use checksums |
3a4e4522ff5cdda0c241981b5231c0ae73289df3cffcf7bc93df1388eb56967a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Security for fastapi-license 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.