The product is Voelin (app id io.github.faumaray.Voelin), everywhere: - crates tsc-* -> voelin-* (and voelin-fuzz), the desktop binary tsc-desktop -> voelin, the development CLI tsctl -> voelinctl; - the Android app: applicationId, Kotlin package io.github.faumaray.voelin, VoelinApp, libvoelin_android.so (JNI class names follow); - TSC_* environment variables -> VOELIN_*, Gradle properties tsc.* -> voelin.*, signing secrets VOELIN_SIGNING_*; - the data/config/cache/state folder tsc -> voelin, the keyring service, thread names, the dev compose project; - desktop file, metainfo, icon, Flatpak manifest, NSIS installer, docs. The gateway keeps its name: bin tsgw (crate voelin-gateway), TSGW_* env vars, the tsgw.v1+json protocol, the tsgw image. The window title and the About page show "Voelin <version>" from voelin_platform::APP_NAME. Packages (scripts/package.sh): the app only (voelin, voelin.exe, APKs, Flatpak). voelinctl is a development tool and in no package. tsgw is for servers and now its own Linux package, tsgw_<v>_amd64.deb and tsgw-<v>-linux-x86_64.tar.gz, with a sandboxed systemd unit (packaging/linux/tsgw.service; /etc/tsgw config, /var/lib/tsgw state) and dependencies of its own (no GUI libraries). docs/gateway-admin.md has an Install section. Fixes: - package-windows: makensis on Windows found no file through "D:/a/..." paths; pass Windows paths (cygpath -w). - StartupWMClass is the app id, which the app sets as its X11 WM_CLASS (it was the binary name, so desktops could not match the window). - Gradle wrapper download timeout 10 s -> 60 s (slow proxies). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
92 lines
2.4 KiB
Rust
92 lines
2.4 KiB
Rust
//! Storage for passwords and credentials.
|
|
|
|
use std::collections::HashMap;
|
|
use std::sync::Mutex;
|
|
|
|
use crate::Result;
|
|
|
|
/// Key-value secret storage. `key` names what the secret is for, e.g.
|
|
/// `bookmark/3/server-password` or `bookmark/3/query-password`.
|
|
pub trait Secrets: Send + Sync {
|
|
fn get(&self, key: &str) -> Result<Option<String>>;
|
|
fn set(&self, key: &str, value: &str) -> Result<()>;
|
|
fn delete(&self, key: &str) -> Result<()>;
|
|
}
|
|
|
|
/// In-memory secrets, for tests and platforms without a keyring.
|
|
#[derive(Default)]
|
|
pub struct MemorySecrets(Mutex<HashMap<String, String>>);
|
|
|
|
impl Secrets for MemorySecrets {
|
|
fn get(&self, key: &str) -> Result<Option<String>> {
|
|
Ok(self.0.lock().unwrap().get(key).cloned())
|
|
}
|
|
|
|
fn set(&self, key: &str, value: &str) -> Result<()> {
|
|
self.0.lock().unwrap().insert(key.to_string(), value.to_string());
|
|
Ok(())
|
|
}
|
|
|
|
fn delete(&self, key: &str) -> Result<()> {
|
|
self.0.lock().unwrap().remove(key);
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
/// The platform keyring: Secret Service on Linux, Credential Manager on
|
|
/// Windows, Keychain on macOS.
|
|
#[cfg(feature = "keyring")]
|
|
pub struct KeyringSecrets {
|
|
service: String,
|
|
}
|
|
|
|
#[cfg(feature = "keyring")]
|
|
impl KeyringSecrets {
|
|
/// `service` distinguishes this application's entries, e.g. the app id.
|
|
pub fn new(service: impl Into<String>) -> Self {
|
|
Self { service: service.into() }
|
|
}
|
|
|
|
fn entry(&self, key: &str) -> Result<keyring::Entry> {
|
|
keyring::Entry::new(&self.service, key).map_err(|e| crate::Error::Secrets(e.to_string()))
|
|
}
|
|
}
|
|
|
|
#[cfg(feature = "keyring")]
|
|
impl Secrets for KeyringSecrets {
|
|
fn get(&self, key: &str) -> Result<Option<String>> {
|
|
match self.entry(key)?.get_password() {
|
|
Ok(v) => Ok(Some(v)),
|
|
Err(keyring::Error::NoEntry) => Ok(None),
|
|
Err(e) => Err(crate::Error::Secrets(e.to_string())),
|
|
}
|
|
}
|
|
|
|
fn set(&self, key: &str, value: &str) -> Result<()> {
|
|
self.entry(key)?.set_password(value).map_err(|e| crate::Error::Secrets(e.to_string()))
|
|
}
|
|
|
|
fn delete(&self, key: &str) -> Result<()> {
|
|
match self.entry(key)?.delete_credential() {
|
|
Ok(()) | Err(keyring::Error::NoEntry) => Ok(()),
|
|
Err(e) => Err(crate::Error::Secrets(e.to_string())),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn memory_secrets() {
|
|
let s = MemorySecrets::default();
|
|
assert_eq!(s.get("a").unwrap(), None);
|
|
s.set("a", "1").unwrap();
|
|
assert_eq!(s.get("a").unwrap().as_deref(), Some("1"));
|
|
s.delete("a").unwrap();
|
|
s.delete("a").unwrap();
|
|
assert_eq!(s.get("a").unwrap(), None);
|
|
}
|
|
}
|