security: improve credential encryption and CORS configurability

Security improvements based on code review:

1. Credential Encryption (Critical)
   - Replace XOR obfuscation with AES-256-GCM encryption
   - Derive key from machine ID (tied to specific machine)
   - Add migration support for legacy XOR format
   - Automatic re-encryption on first load of legacy credentials

2. HTTPS Default (Medium)
   - Change default `secure` setting to `true` for new installs
   - Existing users keep their current setting

3. Configurable CORS Origins (High)
   - Replace hardcoded domain whitelist with SQLite-backed storage
   - Default origins: vicrodh.github.io, control.qbz.lol
   - Add commands: get/add/remove origins, restore defaults
   - Origins can be customized for third-party clients
   - Server restarts automatically when origins change

New dependencies:
   - aes-gcm: AES-256-GCM authenticated encryption
   - sha2: SHA-256 for key derivation
This commit is contained in:
vicrodh committed 2026-02-03 12:36:18 -06:00
1 parent 8e7d9de754
commit 2818ac4d29
6 files changed
+523 -38

No files matched your search

+2
View File
@@ -98,4 +98,6 @@ pub use legal_settings::{
pub use remote_control_settings::{
RemoteControlSettings,
RemoteControlSettingsState,
AllowedOrigin,
AllowedOriginsState,
};