30 lines
1.9 KiB
Markdown
30 lines
1.9 KiB
Markdown
# Micro License Server
|
||
|
||
A very small, self-hosted license server intended for lower traffic projects.
|
||
|
||
## Environment Setup
|
||
|
||
Replace the placeholder secrets in `.env` with secure random values using `openssl rand`:
|
||
|
||
```bash
|
||
sed -i \
|
||
-e "s/PG_CHANGEME/$(openssl rand -base64 32)/" \
|
||
-e "s/API_CHANGEME/$(openssl rand -base64 48)/" \
|
||
.env
|
||
```
|
||
|
||
## API Endpoints
|
||
|
||
All authenticated endpoints expect a `Bearer` token via the `Authorization` header that matches `API_KEY` from `.env`. Unless stated otherwise, responses are JSON.
|
||
|
||
| Method | Path | Auth | Description | Key Request Parameters | Response Highlights |
|
||
| --- | --- | --- | --- | --- | --- |
|
||
| `GET` | `/` | No | Returns server metadata. | – | `{"version": "Micro License Server vX.Y.Z"}` |
|
||
| `POST` | `/license` | Yes | Generates a new license key. | Query: `is_active` (bool, default `true`), `expiration_date` (ISO 8601, optional) | `license_key`, `expiration_timestamp`, `is_active` |
|
||
| `GET` | `/is_valid` | No | Validates a license key and records last usage time. | Query: `license_key` (required) | Boolean validity |
|
||
| `POST` | `/license/{license_key}/disable` | Yes | Deactivates a license key. | Path: `license_key` | `license_key`, `is_active: false` |
|
||
| `POST` | `/license/{license_key}/enable` | Yes | Reactivates a license key. | Path: `license_key` | `license_key`, `is_active: true` |
|
||
| `POST` | `/license/{license_key}/expiration` | Yes | Sets or clears a license key expiration. | Path: `license_key`; Query: `expiration_date` (ISO 8601 or omit to clear) | `license_key`, `expiration_timestamp` (nullable) |
|
||
| `GET` | `/license/export` | Yes | Exports license inventory as CSV ordered by issue time. | – | CSV with `license_key,issue_timestamp,expiration_timestamp,is_active` |
|
||
| `GET` | `/history/export` | Yes | Exports audit history as CSV. | Query: `token` (optional substring filter) | CSV with `action,timestamp` |
|