feat: add signed client upgrade policies
Co-Authored-By: Craft Agent <agents-noreply@craft.do>
This commit is contained in:
1
backend/migrations/000012_update_policies.down.sql
Normal file
1
backend/migrations/000012_update_policies.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS product_update_policies;
|
||||
18
backend/migrations/000012_update_policies.up.sql
Normal file
18
backend/migrations/000012_update_policies.up.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
CREATE TABLE product_update_policies (
|
||||
product_id BIGINT UNSIGNED NOT NULL,
|
||||
platform VARCHAR(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
||||
arch VARCHAR(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
||||
channel VARCHAR(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
||||
enabled BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
release_id BIGINT UNSIGNED NOT NULL,
|
||||
minimum_supported_version VARCHAR(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
|
||||
enforce_after TIMESTAMP(6) NULL,
|
||||
message TEXT NOT NULL,
|
||||
revision BIGINT UNSIGNED NOT NULL DEFAULT 1,
|
||||
updated_by BIGINT UNSIGNED NOT NULL,
|
||||
updated_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
|
||||
PRIMARY KEY (product_id,platform,arch,channel),
|
||||
CONSTRAINT fk_update_policy_product FOREIGN KEY (product_id) REFERENCES products(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_update_policy_release FOREIGN KEY (release_id) REFERENCES product_releases(id),
|
||||
CONSTRAINT fk_update_policy_admin FOREIGN KEY (updated_by) REFERENCES admins(id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
@@ -29,3 +29,5 @@ On 2026-09-30, a dedicated MySQL 8.0 container was used to verify an empty datab
|
||||
Schema 10 adds unique administrator usernames. Existing accounts become `admin-{id}` and retain their passwords; login requests must send `username` instead of `email`. Run migrations before starting the current server or `admin-init`.
|
||||
|
||||
Schema 11 adds nullable `license_instances.secret_encrypted`. Apply before API startup. Configure `LICENSE_CREDENTIAL_ENCRYPTION_KEY_FILE` as an absolute path to an independent 32-byte raw random key. Mount read-only, back up securely with the database, and never commit it. Missing key preserves first-return-only creation. Existing hashes cannot recover secrets. Losing/changing the key makes ciphertext unreadable; rotation is not implemented. Down migration deletes retained ciphertext and requires backup and confirmation.
|
||||
|
||||
Schema 12 adds `product_update_policies`, one policy per product/platform/architecture/channel. Apply before enabling the update-policy administrator UI or `/instances/:instance_id/updates/check`. Only published stable-SemVer releases can be policy targets; the minimum supported version cannot exceed the target. The update response is signed with the configured current P-256 key and expires after 15 minutes. Down migration deletes policy rows and requires an operator-reviewed backup/confirmation. Existing portal snapshot and download APIs remain compatible.
|
||||
|
||||
Reference in New Issue
Block a user