Skip to content

License Server Administration

Shardian solvers validate license status at initialization against a secure licensing server. This page details the database schema, administrative API endpoints, systemd services, and the CLI key management tool.


1. Database Schema

The license server uses a lightweight, transactional SQLite database (licenses.db) located in the root of the server runtime path.

erDiagram
    LICENSES {
        string api_key PK
        string scope "both | aero | atmos"
        integer active "1 = active, 0 = revoked"
        datetime expires_at
        datetime created_at
    }

Table: licenses

  • api_key (TEXT, Primary Key): The cryptographically secure API key string prefixed with sk_live_shardian_.
  • scope (TEXT): Defines the products the license is authorized to run (aero, atmos, or both).
  • active (INTEGER): Actively toggled status. Set to 1 for active, 0 for revoked.
  • expires_at (DATETIME): Expiration timestamp. Pings after this time will return HTTP 401.
  • created_at (DATETIME): Registration timestamp.

2. API Endpoints

The license server exposes two primary groups of API endpoints:

A. Solver Verification (Public)

Used by OpenFOAM and WRF during boundary-layer/turbulence model initialization.

  • GET /v1/verify
    • Headers: Authorization: Bearer <api_key>
    • Response (200 OK):
      {"status":"valid","key":"sk_live_shardian_...","scope":"both","expires_at":"2027-06-15T00:00:00Z"}
      
    • Response (401 Unauthorized):
      {"status":"invalid","reason":"Key expired or does not exist"}
      

B. Administrative API (Private / Internal-Only)

Protected by basic authentication and restricted to loopback (127.0.0.1) or trusted internal networks.

  • POST /v1/admin/keys
    • Description: Creates and registers a new license key.
    • Body:
      {"scope": "both", "days_valid": 180}
      
    • Response (200 OK):
      {"key": "sk_live_shardian_aero_atmos_2026_eval_abcdef", "status": "active"}
      
  • DELETE /v1/admin/keys
    • Description: Instantly revokes an active key.
    • Body:
      {"key": "sk_live_shardian_..."}
      

3. The CLI Key Management Tool

Developers can manage license keys on the VPS host using the compiled Go CLI utility license-cli:

Generating a New Key:

./license-cli create --scope both --days 365
Output:
License Key Generated Successfully!
Key:    sk_live_shardian_cfd_atmos_2026_eval_4a2c91
Scope:  both
Expiry: 2027-06-15 12:00:00 UTC
Status: Registered in licenses.db (active)

Revoking a Key:

./license-cli revoke --key sk_live_shardian_cfd_atmos_2026_eval_4a2c91
Output:
Success: Key sk_live_shardian_cfd_atmos_2026_eval_4a2c91 has been deactivated (active=0).
Any simulation using this key will abort immediately at the next time step.


4. Systemd Daemon Configuration

On the production VPS server, the license Go API is managed by systemd as a persistent daemon:

# /etc/systemd/system/shardian-license-server.service
[Unit]
Description=Shardian License Verification API Server
After=network.target

[Service]
Type=simple
User=shardian-admin
WorkingDirectory=/var/www/license-server
ExecStart=/var/www/license-server/server
Restart=always
RestartSec=5
Environment=PORT=8080
Environment=DB_PATH=/var/www/license-server/licenses.db

[Install]
WantedBy=multi-user.target

To reload and monitor the daemon:

sudo systemctl daemon-reload
sudo systemctl restart shardian-license-server.service
sudo systemctl status shardian-license-server.service