Add admin and customer interfaces, orders, signed activation and leases, protected package delivery, keyring verification, migrations, security controls, tests and deployment documentation. Co-Authored-By: Craft Agent <agents-noreply@craft.do>
38 lines
6.2 KiB
Markdown
38 lines
6.2 KiB
Markdown
# DEV-KEYRING-v2 / client execution draft
|
|
|
|
Status: configurable development implementation, not T01/T02-approved production protocol. Existing 18081 unchanged. No commits/releases.
|
|
|
|
## Environment and wire format
|
|
|
|
LICENSE_KEYRING_FILE is an absolute JSON file (regular file, <=64 KiB). Structure:
|
|
|
|
```json
|
|
{"current_key_id":"release_2026_10","keys":[{"key_id":"release_2026_10","public_key_pem":"PUBLIC PEM ONLY","revoked":false},{"key_id":"previous","public_key_pem":"PUBLIC PEM ONLY","revoked":false}]}
|
|
```
|
|
|
|
The current private key still comes exclusively from existing protected LICENSE_SIGNING_PRIVATE_KEY_FILE or the existing PEM injection mechanism; do not put private keys in the keyring. Each unique key ID uses [a-zA-Z0-9_-]{1,64}. Maximum 32 entries. Current entry must exist, be non-revoked, be P256 and match the private key or startup fails. Retired verification-only entries need no private key.
|
|
|
|
With keyring configured, NEW certificates use license-v2 and NEW heartbeat leases use lease-v2. The existing fixed canonical v1 field order is retained, with the new version and a final newline followed by key_id=<ID>. No trailing newline. SHA256, ECDSA P256, ASN.1 DER signature, raw standard base64 (no padding). key_id belongs INSIDE payload and is signed. IDs in Node are positive safe integers; client rejects larger numeric IDs rather than accepting rounded JSON integers. RFC3339 UTC times remain exact signed text, not reformatted by client.
|
|
|
|
Without keyring, old v1 signing remains for development compatibility. The new client intentionally refuses all v1 payloads. /api/v1/activation/keyring exposes public metadata, but is discovery ONLY; never trust it automatically. Public keys and revocation policy must be pinned/distributed through a separately authenticated deployment path. Unknown/revoked key fails closed. A revoked signing key cannot be current.
|
|
|
|
## Migration and rollback
|
|
|
|
No historical SQL migration changed and no new schema migration required: certificate_payload and operation response JSON persist version and key_id; certificate_version stores v2. Existing idempotent activation/heartbeat operations replay original responses without re-signing, including v1. Retry with the SAME idempotency key, never assume replay upgrades a certificate.
|
|
|
|
Stage clients and pinned old+new keys BEFORE switching the API current key. Keep old unrevoked PUBLIC key for the full approved historical certificate/lease lifetime, then retire only after explicit lifecycle review. Do not overwrite key IDs with different public keys. Server validates current configuration only; deployment approval must enforce key ID immutability/history. Runtime reload is NOT supported; use approved rolling deployments with persistent protected injection. No current production key was generated or rotated.
|
|
|
|
Rollback is configuration/software rollout, not business-data down migration: restore previous API image plus its matching current private key and public keyring while preserving public keys needed for already-issued v2 payloads. Rolling back to a v1-only binary DOES NOT make v2 artifacts verifiable by old clients. Do not delete stored responses/certificates or force schema version. Preserve quiesced backup, issued artifacts and approvals. Formal retention windows, emergency revocation publication, config generation monotonicity and live business rotation drill remain gates.
|
|
|
|
## Independent client module
|
|
|
|
client/verify.mjs is a Node server-side reference package, NOT the management console and NOT a deployed customer integration. No instance secret/session stored by this module. verifyEnvelope takes caller-pinned keys, rejects unknown/revoked, altered key_id or payload. acceptLease verifies instance binding, signed state, entitlement bound, max14-day lease, 5-minute server skew, monotonic client/server milliseconds. canRunOffline checks previously accepted lease until expiration. Caller must atomically persist returned state BEFORE enabling licensed work, update local high-water before EVERY subsequent execution, protect it from tampering and disable on all errors. This does not resist privileged cloning, disk snapshot rollback or clock manipulation by host owner; monotonic trusted time/storage design still requires T01 approval. Millisecond comparison loses sub-ms precision; server-issued microsecond exact ordering and replay digest persistence are future hardening gates.
|
|
|
|
Go test TestKeyringCrossLanguageRotation generates public Go->Node vectors with ephemeral private keys only in memory. Checks old/current certificate verification, revoked/unknown rejection, signed key substitution/payload tamper rejection, lease verification, instance mismatch, local/server high-water rollback, offline expiry. No private test fixture committed. This is cross-language component evidence, not authenticated activation/heartbeat rotation E2E. Node required for backend tests; CI explicitly installs Node24.
|
|
|
|
## Integrator API / customer portal boundary
|
|
|
|
Provisioning remains administrator-only POST /api/v1/licenses/:id/instances, returning a one-time secret that must reach the authorized integrator via secure channel. Client activation POST /api/v1/activation/instances/:instance_id uses secret + license_key and Idempotency-Key. Heartbeat POST /api/v1/instances/:instance_id/heartbeat uses secret + client_time and Idempotency-Key; follow the current heartbeat draft field contract. Download POST /api/v1/customers/:customer_id/releases/:id/download uses existing credential draft and Nginx internal handoff. No secret belongs in query strings/logs/browser localStorage. Timeouts/429 use bounded backoff; 403/409 must not silently reactivate, bypass checks or reuse mismatched payloads.
|
|
|
|
There is NO customer-account authentication domain or customer portal in the current implementation. The Vue UI is administrator management only. T25 remains unstarted, pending tenant identity/account reset/RBAC/renewal contracts. Do not build an unauthenticated customer-data page using administrator cookies or pretend this module is a customer portal. Minimum future portal: customer login/session isolation, only-own licenses/orders/leases/releases, no administrator routes, secure secret delivery/recovery, expiry/renewal requests, logout/reset and tenant-negative tests.
|