mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-28 21:44:38 +00:00
1.6 KiB
1.6 KiB
Secret Key Keychain Migration
Goal
Move the SecretStore master encryption key out of .secret_key files and into the OS keychain for real app environments.
Accepted exception:
- unit tests and explicit debug overrides may keep using file-backed storage.
Current State
- Auth/provider credentials already prefer the keychain when available.
SecretStorestill keeps its master key in{openhuman_dir}/.secret_key.keyringcurrently falls back to a file backend in some non-test environments.
Target State
dev,staging, andproduse the OS keychain for theSecretStoremaster key.- Existing ciphertext stays on disk unchanged.
- Existing
.secret_keyfiles are migrated into the keychain and then deleted only after verification. - Unit tests continue to work without depending on the host OS keychain.
Migration Plan
- Change keyring backend selection so
cfg(test)keeps the file backend, but normal app environments default to the OS backend unless explicitly overridden. - Teach
SecretStoreto:- derive a stable keychain namespace from the user/openhuman directory
- migrate an existing
.secret_keyfile into the keychain - create the key in keychain when no legacy file exists
- fall back safely when keychain is unavailable
- Add tests for:
- legacy
.secret_keymigration - post-migration decrypt compatibility
- unit-test file-backed behavior
- legacy
Constraints
- Never re-encrypt existing payloads unless the ciphertext format itself changes.
- Never delete
.secret_keyuntil the keychain write is verified. - Keep an explicit override path for debugging and recovery.