Dependency-free Python client for a local license-agent, with optional FastAPI enforcement helpers.
Project description
license-agent-client
A lightweight Python client and FastAPI helpers for enforcing licensing via a local license-agent service.
This package is designed for applications such as Logzy, MeyiConnect, or any product that uses a centralized licensing model:
Application → license-agent → license-platform
It eliminates duplicated license-handling code and provides a single, consistent way to:
- Check license status
- Activate licenses
- Lookup license information
- Enforce license rules at API level
- Keep activation UI accessible while blocking product APIs
Install
Core client (no framework dependency)
pip install license-agent-client
With FastAPI helpers (recommended)
pip install "license-agent-client[fastapi]"
Environment variables
| Variable | Default | Description |
|---|---|---|
| LICENSE_AGENT_URL | http://license-agent:8090 |
Base URL of local license-agent |
| LICENSE_CACHE_SECONDS | 30 |
Cache TTL (seconds) |
| LICENSE_TIMEOUT_SECONDS | 2 |
HTTP timeout |
| REQUIRE_LICENSE | false |
Enable license enforcement |
Core usage (plain Python)
from license_agent_client import get_client, LicenseInactiveError
client = get_client()
try:
client.assert_active()
except LicenseInactiveError as e:
print("License blocked:", e)
raise SystemExit(1)
FastAPI integration
from fastapi import FastAPI
from license_agent_client.router import get_license_router
from license_agent_client.middleware import install_license_gate
app = FastAPI()
app.include_router(get_license_router(prefix="/v1/license"))
install_license_gate(app)
License lifecycle behavior
| Platform action | Agent behavior | App behavior |
|---|---|---|
| Install | pending | blocked |
| Approved | activation allowed | unlocked |
| Deactivated | check-in fails | blocked |
| Rejected | new key allowed | reinstall |
Block APIs when license is inactive (global gate)
from fastapi import FastAPI from license_agent_client.middleware import install_license_gate
app = FastAPI()
install_license_gate( app, exempt_prefixes=( "/ui", "/health", "/v1/license", ), )
Typical FastAPI app layout
from fastapi import FastAPI from fastapi.staticfiles import StaticFiles from license_agent_client.router import get_license_router from license_agent_client.middleware import install_license_gate
app = FastAPI()
Serve activation UI
app.mount("/ui", StaticFiles(directory="/app/ui", html=True))
License APIs
app.include_router(get_license_router(prefix="/v1/license"))
Global license enforcement
install_license_gate(app)
Fetch license limits
limits = get_client().limits() print(limits)
Activate a license (proxy to agent)
from license_agent_client import get_client
resp = get_client().activate( license_key="XXXX-YYYY-ZZZZ", product_code="logzy", fingerprint="node-1", version="1.2.3", vm_meta={"hostname": "prod-node-1"}, )
print(resp)
License info lookup (proxy to agent → platform)
info = get_client().license_info(license_key="XXXX-YYYY-ZZZZ") print(info)
How apps use it (default UI)
from fastapi import FastAPI from license_agent_client.ui import mount_default_ui from license_agent_client.router import get_license_router from license_agent_client.middleware import install_license_gate
app = FastAPI()
mount_default_ui(app) # ✅ mounts built-in /ui app.include_router(get_license_router(prefix="/v1/license")) install_license_gate(app, exempt_prefixes=("/ui", "/health", "/v1/license"))
How apps override it (custom UI)
from fastapi.staticfiles import StaticFiles
override built-in UI
app.mount("/ui", StaticFiles(directory="/app/my-ui", html=True), name="custom-ui")
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file license_agent_client-1.0.1.tar.gz.
File metadata
- Download URL: license_agent_client-1.0.1.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00064a4ef148b874cda7184c220d79a66960951d1e25ec23a3dad87f156de226
|
|
| MD5 |
79681564c96ca69fb2c130ab6936e127
|
|
| BLAKE2b-256 |
2257b39b96f14747343b719cf7dcfae1f904e0544fa2e134330806d9fe7e317e
|
File details
Details for the file license_agent_client-1.0.1-py3-none-any.whl.
File metadata
- Download URL: license_agent_client-1.0.1-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1642d21b2c6769348a0544bf36d93d8554e5e0b8daacc36f683869d9d213aded
|
|
| MD5 |
89aafa15d51fc459510d4e75ba52605f
|
|
| BLAKE2b-256 |
ae958902033281be3ccaa63424d400e04885f4117eda60dfa69f31016925ba83
|