feat(api): give status page servers sealed key-value storage

Certificates and ACME keys are stored encrypted in the database,
namespaced per owner so an organization's servers cannot read platform
or other organizations' keys. Locks live in Redis and expire.

Refs #22

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 08:54:08 +01:00
1 parent f52ae33cf0
commit 46f1f82481
11 files changed
+611 -1

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
-- name: StorageGet :one
SELECT value, modified FROM agent_storage WHERE owner = $1 AND key = $2;
-- name: StoragePut :exec
INSERT INTO agent_storage (owner, key, value) VALUES ($1, $2, $3)
ON CONFLICT (owner, key) DO UPDATE SET value = EXCLUDED.value, modified = now();
-- name: StorageDelete :execrows
-- Deletes key and, as certmagic expects, everything below it.
DELETE FROM agent_storage
WHERE owner = sqlc.arg(owner) AND (key = sqlc.arg(key) OR starts_with(key, sqlc.arg(key)::text || '/'));
-- name: StorageList :many
SELECT key, length(value)::bigint AS size, modified FROM agent_storage
WHERE owner = sqlc.arg(owner) AND (sqlc.arg(prefix)::text = '' OR starts_with(key, sqlc.arg(prefix)::text || '/'))
ORDER BY key;