feat: mount spaces/folders over SFTP with SSH-key auth

Add an in-process SFTP server (russh) backed directly by the nodes
table, so a space can be edited from nvim or synced with sshfs without
a separate filesystem mirror. Access is authenticated by public key
against a new ssh_keys table, managed via :sshkey in the app; the
feature stays off until WORKSPACE_SFTP_BIND is set.
This commit is contained in:
nvrl committed 2026-09-21 15:36:36 +02:00
1 parent ab8712559e
commit 747332153c
12 files changed
+1950 -93

No files matched your search

+26
View File
@@ -18,6 +18,25 @@ pub struct Config {
pub secure_cookie: bool,
pub backup: BackupConfig,
pub mail: MailConfig,
pub sftp: SftpConfig,
}
/// The SFTP mount. Dormant until `WORKSPACE_SFTP_BIND` is set — same shape as
/// the mail relay, because a workspace with no key registered yet should not
/// refuse to start over a feature nobody has turned on.
#[derive(Debug, Clone)]
pub struct SftpConfig {
pub bind: Option<SocketAddr>,
}
impl SftpConfig {
fn from_env() -> Result<Self> {
let bind = var("SFTP_BIND")
.map(|v| v.parse())
.transpose()
.context("WORKSPACE_SFTP_BIND must look like 127.0.0.1:2222")?;
Ok(Self { bind })
}
}
/// Time of day in the configured timezone, as `HH:MM`.
@@ -194,6 +213,7 @@ impl Config {
secure_cookie,
backup: BackupConfig::from_env()?,
mail: MailConfig::from_env()?,
sftp: SftpConfig::from_env()?,
})
}
@@ -206,6 +226,12 @@ impl Config {
pub fn proton_session_path(&self) -> PathBuf {
self.data_dir.join("proton-session.json")
}
/// The SFTP server's own identity, generated once on first boot. Losing it
/// only costs a host-key warning on every client, never data.
pub fn sftp_host_key_path(&self) -> PathBuf {
self.data_dir.join("sftp_host_key")
}
}
impl MailConfig {