mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-12-01 09:24:46 +00:00
feat(keyring): end-to-end encrypted keyring for SSH keys and key pairs, optional cloud sync (CLI 0.12.0)
`logicsrc keyring` (alias `kr`; `keys` is API keys): add/gen/list/show/restore/ rm/export --pub/sync/status. A keyring is an OpenCreds user-profile vault (same PBKDF2-600k + HKDF + AES-256-GCM scheme as `logicsrc vault`, recovery key); each private key is an OpenCreds `key` item envelope, public halves stay readable. Works fully local under ~/.config/logicsrc/keyring; `keyring sync` pushes ciphertext to the account. restore writes the default file name, 600/644, refuses a different existing key without --force and backs it up first; private keys are printed only with --print-private. - apps/pwa: /api/keyring (person Bearer key; session read-only; machine keys refused), additive migration 008_keyring, server refuses any upload that carries plaintext private key material (incl. base64'd PEM "ciphertext"); /keyring page lists public halves and decrypts in the browser (WebCrypto, same derivation) for download. - logicsrc-mcp: list/show/export_authorized_keys/add (sealed only)/remove/ restore instructions; never returns a private key. - docs/keyring.md served at /docs/keyring. - Tests: crypto round trip, ssh-keygen fingerprint parity, AAD binding, restore perms + overwrite guard + backup, two-machine sync, server stores ciphertext only, browser decrypt opens CLI-sealed envelopes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ae4615e61d
commit
1bff3e975c
21 changed files with 2168 additions and 3 deletions
33
apps/pwa/src/migrations/008_keyring.sql
Normal file
33
apps/pwa/src/migrations/008_keyring.sql
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
-- The keyring (`logicsrc keyring`): SSH keys and other key pairs, synced to the
|
||||
-- account. Additive only. Zero-knowledge like opencreds: meta is OpenCreds
|
||||
-- VaultMeta (the user key wrapped under the keyring passphrase), and each
|
||||
-- entry's private key is an AES-GCM envelope under that user key. The public
|
||||
-- half (name, type, public key, fingerprint, comment) is stored in the clear
|
||||
-- on purpose: it is public, and the web page lists it without a passphrase.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS keyring_vaults (
|
||||
user_id TEXT PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
|
||||
meta TEXT NOT NULL,
|
||||
created_at INTEGER NOT NULL,
|
||||
updated_at INTEGER NOT NULL
|
||||
);
|
||||
|
||||
-- envelope NULL + deleted_at set = a tombstone, kept so the removal reaches
|
||||
-- every other machine. updated_at is the client's clock (ms), used for
|
||||
-- last-writer-wins.
|
||||
CREATE TABLE IF NOT EXISTS keyring_entries (
|
||||
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
id TEXT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
key_type TEXT NOT NULL,
|
||||
filename TEXT NOT NULL,
|
||||
public_key TEXT NOT NULL,
|
||||
fingerprint TEXT NOT NULL,
|
||||
comment TEXT NOT NULL DEFAULT '',
|
||||
envelope TEXT,
|
||||
created_at INTEGER NOT NULL,
|
||||
updated_at INTEGER NOT NULL,
|
||||
deleted_at INTEGER,
|
||||
PRIMARY KEY (user_id, id)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_keyring_entries_user ON keyring_entries(user_id, updated_at);
|
||||
Loading…
Add table
Add a link
Reference in a new issue