feat: desktop — connexion compte central + environnement prod/dev (#230)
CI / lint (push) Failing after 29s
CI / test (push) Skipped
CI / build (push) Skipped
CI / e2e (push) Skipped
CI / security (push) Failing after 16s

Liaison d'appareil sur og/og-dev, validation du jeton draco et ouverture de la session de l'admin local. Sélecteur prod/dev (Configuration + premier lancement), admin local par défaut admin/chab30, sans impact sur le web Docker. Inclut BUG-126 (runtime python-embed/_pth + copie de backend/frontend + signature updater opt-in) et BUG-127 (retour /liaison même hôte).
This commit is contained in:
2026-11-20 07:19:08 -05:00
parent 5794595d88
commit f77b0e6574
34 changed files with 1789 additions and 119 deletions
+1 -1
View File
@@ -2626,7 +2626,7 @@ dependencies = [
[[package]]
name = "obsigate-desktop"
version = "2.87.3"
version = "2.88.0"
dependencies = [
"chrono",
"env_logger",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "obsigate-desktop"
version = "2.87.3"
version = "2.88.0"
description = "ObsiGate Desktop — Porte d'entrée native pour vos vaults Obsidian"
authors = ["Bruno Charest"]
edition = "2021"
+33 -30
View File
@@ -128,42 +128,40 @@ Produits :
### Premier lancement
1. **Lance l'application** (menu ou ligne de commande)
- 💡 *Premier lancement recommandé depuis un terminal* pour voir le mot de passe admin généré
2. Le backend Python démarre automatiquement → health check sur `127.0.0.1:17890`
3. La fenêtre s'ouvre sur l'interface ObsiGate (écran de connexion si l'auth est activée)
4. **Connecte-toi** avec le compte admin créé automatiquement (voir [Compte administrateur](#compte-administrateur))
4. **Connecte-toi** avec le compte admin local **ou** avec ton compte central (voir ci-dessous)
5. **Sélectionne le dossier parent de tes vaults** Obsidian via le sélecteur natif
6. L'indexation démarre automatiquement
### Compte administrateur
### Compte administrateur local
Au premier démarrage, un compte administrateur est créé automatiquement :
Au premier démarrage, un compte administrateur local est créé automatiquement :
- **Login** : `admin` (modifiable via la variable d'environnement `OBSIGATE_ADMIN_USER`)
- **Mot de passe** : généré aléatoirement (16 caractères) et affiché **une seule fois** dans les logs
- **Login** : `admin` (modifiable via `OBSIGATE_ADMIN_USER`)
- **Mot de passe** : `chab30` (défaut desktop, à changer dès la première connexion)
Le mot de passe apparaît dans la sortie du terminal sous cette forme :
```
============================================================
PREMIER DÉMARRAGE — Compte admin créé automatiquement
Utilisateur : admin
Mot de passe : XXXXXXXXXXXXXXXX
CHANGEZ CE MOT DE PASSE dès la première connexion !
============================================================
```
> Ce compte est un **secours local** : le backend n'écoute que sur `127.0.0.1`.
> Il reste utilisable même sans connexion au site central. Pour choisir un autre
> mot de passe initial, définis `OBSIGATE_ADMIN_PASSWORD` avant le tout premier
> lancement (le compte n'est créé qu'une fois).
> ⚠️ **Note le mot de passe immédiatement** — il n'est affiché qu'une seule fois.
> Si tu rates les logs, supprime le dossier `data/` et relance l'application pour
> régénérer un nouveau compte.
### Connexion avec un compte central (#230)
**Prédéfinir le mot de passe** (recommandé) :
L'écran de connexion propose **« Se connecter avec mon compte central »** :
Avant le premier lancement, définis les variables d'environnement suivantes :
1. L'app ouvre la page d'approbation du site central choisi (`og.dracodev.net`
en production, `og-dev.dracodev.net` en développement).
2. Connecte-toi au central si nécessaire, puis **approuve** la liaison
(code affiché dans l'app).
3. Le desktop ouvre la session de l'admin local : aucun mot de passe central
n'est saisi dans la fenêtre.
- **Windows** (PowerShell) : `$env:OBSIGATE_ADMIN_PASSWORD="MonMotDePasse"`
- **Linux** : `export OBSIGATE_ADMIN_PASSWORD="MonMotDePasse"`
Tu peux aussi définir `OBSIGATE_ADMIN_USER` pour changer le nom d'utilisateur.
Le **même environnement** pilote la barre inter-apps : une fois connecté au
central via le navigateur, les autres applications (Flowdeck, TikTak…) s'ouvrent
avec le SSO. L'environnement se choisit au premier lancement et dans
**Configuration → Vaults & dossiers (Desktop)** ; le backend redémarre après le
changement. Aucun impact sur l'application web Docker.
### Lancements suivants
@@ -208,9 +206,11 @@ Le fichier de config desktop est stocké dans :
```json
{
"vaults_path": "/home/bruno/Documents",
"backend_port": 17890,
"theme": "system"
"vault_path": "C:\\Users\\bruno\\ObsiGate",
"vaults": [{ "name": "ObsiGate", "path": "C:\\Users\\bruno\\ObsiGate" }],
"dirs": [],
"environment": "prod",
"wizard_done": true
}
```
@@ -308,9 +308,12 @@ cargo tauri signer generate -w obsigate-updater.key
- La **clé publique** est déjà renseignée dans `plugins.updater.pubkey`
(`tauri.conf.json`).
- La **clé privée** (`desktop/obsigate-updater.key`, gitignorée) est lue
automatiquement par `build-windows.bat` / `build-linux.sh` ; en CI, via les
secrets Gitea `TAURI_SIGNING_PRIVATE_KEY` / `TAURI_SIGNING_PRIVATE_KEY_PASSWORD`.
- La **clé privée** (`desktop/obsigate-updater.key`, gitignorée) est utilisée
automatiquement par `build-windows.bat` / `build-linux.sh` **à condition** que
son mot de passe soit fourni via `TAURI_SIGNING_PRIVATE_KEY_PASSWORD` ; en CI,
via les secrets Gitea `TAURI_SIGNING_PRIVATE_KEY` / `TAURI_SIGNING_PRIVATE_KEY_PASSWORD`.
Sans ce mot de passe, le build se poursuit **sans `.sig`** et sans aucune invite
interactive (`--ci`).
- Le CLI produit des `.sig` par artefact (`*.exe.sig`, `*.AppImage.sig`, …).
**Manifeste `latest.json`** (détection des mises à jour) :
+8 -5
View File
@@ -52,18 +52,21 @@ cp -r ../frontend frontend
echo "✅ Staged"
# ── 2c. Clé de signature des mises à jour (updater Tauri) ──────
if [ -f "obsigate-updater.key" ]; then
export TAURI_SIGNING_PRIVATE_KEY="$(cat obsigate-updater.key)"
# La clé peut être protégée par mot de passe : Tauri CLI le demande alors
# de façon interactive. On ne signe que si le mot de passe est fourni via
# TAURI_SIGNING_PRIVATE_KEY_PASSWORD, sinon les .sig sont désactivés.
if [ -f "obsigate-updater.key" ] && [ -n "${TAURI_SIGNING_PRIVATE_KEY_PASSWORD:-}" ]; then
export TAURI_SIGNING_PRIVATE_KEY_PATH="obsigate-updater.key"
SIGN_CONFIG=""
echo "[2c/5] Clé updater trouvée — artefacts .sig activés"
echo "[2c/5] Clé updater + mot de passe fournis — artefacts .sig activés"
else
SIGN_CONFIG='--config {"bundle":{"createUpdaterArtifacts":false}}'
echo "[2c/5] Clé updater absente — build sans .sig"
echo "[2c/5] Signature updater ignorée (clé absente ou mot de passe non défini) — build sans .sig"
fi
# ── 3. Build Tauri ────────────────────────────────────────────
echo "[3/5] Building Tauri application..."
cargo tauri build --target x86_64-unknown-linux-gnu --bundles deb,appimage $SIGN_CONFIG
cargo tauri build --ci --target x86_64-unknown-linux-gnu --bundles deb,appimage $SIGN_CONFIG
echo "✅ Build successful"
# ── 4. Copier le runtime à côté de l'exécutable ───────────────
+137 -29
View File
@@ -5,14 +5,26 @@ REM Prérequis : Rust, Tauri CLI, NSIS, Python 3.11 embed
REM ============================================================
setlocal enabledelayedexpansion
REM Always run from the script directory, regardless of where the
REM caller invoked us from. Without this, a call like
REM `desktop\build-windows.bat` from the repo root would download into
REM the repo root and, worse, delete the repo's backend/ and frontend/
REM directories in the staging/cleanup steps.
cd /d "%~dp0"
echo ========================================
echo ObsiGate Desktop — Build Windows
echo ========================================
echo.
REM ── 0. Kill any leftover backend from a previous run ──────────
echo [0/6] Killing leftover Python processes...
taskkill /F /IM python.exe 2>nul
REM ── 0. Close a running build so the exe can be replaced ───────
REM Windows verrouille l'exécutable : sans cette étape, cargo échoue
REM avec « Access is denied » si l'application tourne encore.
echo [0/6] Closing running ObsiGate Desktop / embedded backend...
taskkill /F /IM obsigate-desktop.exe >nul 2>&1
REM Only target the python.exe shipped in python-embed/, never the
REM user's own Python installs.
powershell -NoProfile -Command "Get-Process python -ErrorAction SilentlyContinue | Where-Object { $_.Path -like '*\python-embed\python.exe' } | Stop-Process -Force -ErrorAction SilentlyContinue"
echo.
REM ── 1. Vérifier les prérequis ─────────────────────────────────
@@ -23,24 +35,82 @@ echo ✅ Rust + Tauri OK
REM ── 2. Préparer Python 3.11 embed ─────────────────────────────
echo [2/6] Preparing Python embed...
echo 📥 Downloading Python 3.11 embed...
if exist "python-embed" rmdir /s /q "python-embed"
curl -L -o python-embed.zip "https://www.python.org/ftp/python/3.11.9/python-3.11.9-embed-amd64.zip"
powershell Expand-Archive -Path python-embed.zip -DestinationPath python-embed\
del python-embed.zip
if errorlevel 1 (
echo ❌ Cannot remove python-embed - a process is still using it
goto :fail
)
REM Enable pip and site-packages + parent dir for 'import backend'
echo import site >> python-embed\python311._pth
echo ..>> python-embed\python311._pth
echo 📥 Downloading Python 3.11 embed...
curl -L --fail -o python-embed.zip "https://www.python.org/ftp/python/3.11.9/python-3.11.9-embed-amd64.zip"
if errorlevel 1 (
echo ❌ Python embed download failed
goto :fail
)
REM Use the native bsdtar when available: Expand-Archive can fail when a
REM PS7 PSModulePath is inherited by Windows PowerShell (overload error),
REM and its failure is non-fatal (exit code 0), so we verify python.exe
REM afterwards in all cases.
if not exist "python-embed" mkdir "python-embed"
where tar >nul 2>&1
if not errorlevel 1 (
tar -xf python-embed.zip -C python-embed
) else (
powershell -NoProfile -Command "Expand-Archive -Path 'python-embed.zip' -DestinationPath 'python-embed'"
)
if errorlevel 1 (
echo ❌ Python embed extraction failed
goto :fail
)
if not exist "python-embed\python.exe" (
echo ❌ Python embed extraction failed - python.exe missing
goto :fail
)
del /q python-embed.zip
REM Write the ._pth explicitly instead of appending to the archive's
REM file. An embedded Python finds its standard library ONLY through
REM this file: without python311.zip + '.' it cannot import `encodings`
REM and the backend dies before serving a single request (the UI then
REM stays on the unstyled Tauri splash — "CSS is broken").
REM python311.zip → stdlib
REM . → python-embed\ (DLLs, .pyd)
REM import site → enables Lib\site-packages
REM .. → exe dir (so `import backend` works next to the .exe)
(
echo python311.zip
echo .
echo import site
echo ..
) > python-embed\python311._pth
REM Download get-pip.py (embed Python doesn't include ensurepip)
echo 📥 Downloading get-pip.py...
curl -L -o get-pip.py "https://bootstrap.pypa.io/get-pip.py"
curl -L --fail -o get-pip.py "https://bootstrap.pypa.io/get-pip.py"
if errorlevel 1 (
echo ❌ get-pip.py download failed
goto :fail
)
python-embed\python.exe get-pip.py --no-cache-dir
del get-pip.py
if errorlevel 1 (
echo ❌ pip bootstrap failed
goto :fail
)
del /q get-pip.py
REM Install dependencies
python-embed\python.exe -m pip install --no-cache-dir -r ..\backend\requirements.txt
if errorlevel 1 (
echo ❌ Python dependencies installation failed
goto :fail
)
REM Fail fast if the runtime is unusable (missing stdlib / deps).
python-embed\python.exe -c "import encodings, uvicorn, fastapi, pyotp"
if errorlevel 1 (
echo ❌ python-embed sanity check failed ^(stdlib or deps missing^)
goto :fail
)
echo ✅ Python embed ready
REM ── 2b. Copier backend + frontend localement pour le bundle ────
@@ -52,10 +122,24 @@ xcopy /E /I /Q /Y "..\frontend" "frontend"
echo ✅ Staged
REM ── 2c. Clé de signature des mises à jour (updater Tauri) ──────
REM La clé privée peut être protégée par mot de passe. Tauri CLI
REM demande alors ce mot de passe de façon interactive (une fois par
REM invocation, donc deux fois à cause du repli NSIS) — impossible à
REM fournir dans un script non surveillé. On ne signe donc que si le
REM mot de passe est explicitement fourni dans l'environnement :
REM set TAURI_SIGNING_PRIVATE_KEY_PASSWORD=*** & build-windows.bat
REM Sinon les artefacts .sig sont désactivés, sans aucune invite.
set "SIGN_CONFIG="
if exist "obsigate-updater.key" (
set /p TAURI_SIGNING_PRIVATE_KEY=<obsigate-updater.key
echo [2c/6] Cle updater trouvee - artefacts .sig actives
if defined TAURI_SIGNING_PRIVATE_KEY_PASSWORD (
set "TAURI_SIGNING_PRIVATE_KEY_PATH=obsigate-updater.key"
echo [2c/6] Cle updater + mot de passe fournis - artefacts .sig actives
) else (
> updater-off.json echo {"bundle":{"createUpdaterArtifacts":false}}
set "SIGN_CONFIG=--config updater-off.json"
echo [2c/6] Cle updater presente mais TAURI_SIGNING_PRIVATE_KEY_PASSWORD non defini
echo [2c/6] Build sans artefacts .sig ^(aucune invite de mot de passe^)
)
) else (
> updater-off.json echo {"bundle":{"createUpdaterArtifacts":false}}
set "SIGN_CONFIG=--config updater-off.json"
@@ -64,32 +148,39 @@ if exist "obsigate-updater.key" (
REM ── 3. Build Tauri ────────────────────────────────────────────
echo [3/6] Building Tauri application (NSIS + MSI installers)...
cargo tauri build --target x86_64-pc-windows-msvc --bundles nsis,msi %SIGN_CONFIG%
REM `--ci` interdit toute invite interactive (dont le mot de passe de
REM la clé updater) : en cas de valeur manquante, le build échoue
REM proprement au lieu de bloquer le terminal.
cargo tauri build --ci --target x86_64-pc-windows-msvc --bundles nsis,msi %SIGN_CONFIG%
if errorlevel 1 (
echo ⚠️ Standard bundle build failed, trying fallback to NSIS only...
cargo tauri build --target x86_64-pc-windows-msvc --bundles nsis %SIGN_CONFIG%
cargo tauri build --ci --target x86_64-pc-windows-msvc --bundles nsis %SIGN_CONFIG%
if errorlevel 1 (
echo ❌ Build failed!
goto :cleanup
goto :fail
)
)
echo ✅ Build successful
REM ── 4. Copier python-embed vers output dir (dev local) ─────────
echo [4/6] Copying python-embed to output dir...
REM ── 4. Copier le runtime vers l'output dir (exe lancé sur place) ─
REM L'exe résout `python-embed/python.exe`, `backend/` (PYTHONPATH) et
REM `frontend/` (fichiers statiques servis par FastAPI) *à côté de lui*.
REM Sans ces trois dossiers, l'exe ne démarre aucun backend : la fenêtre
REM reste sur le HTML embarqué par Tauri, dont les liens /static/* ne
REM résolvent pas → interface sans CSS.
echo [4/6] Copying runtime (python-embed, backend, frontend)...
set "OUTDIR=target\x86_64-pc-windows-msvc\release"
if exist "%OUTDIR%\python-embed" rmdir /s /q "%OUTDIR%\python-embed" 2>nul
xcopy /E /I /Q /Y "python-embed" "%OUTDIR%\python-embed"
echo ..>> "%OUTDIR%\python-embed\python311._pth"
for %%D in (python-embed backend frontend) do (
if exist "%OUTDIR%\%%D" rmdir /s /q "%OUTDIR%\%%D"
xcopy /E /I /Q /Y "%%D" "%OUTDIR%\%%D" >nul
if errorlevel 1 (
echo ❌ Copy of %%D to %OUTDIR% failed
goto :fail
)
)
echo ✅ Dev runtime ready
:cleanup
REM ── 5. Nettoyer les dossiers stagés ───────────────────────────
echo [5/6] Cleaning up staged dirs...
if exist "backend" rmdir /s /q "backend"
if exist "frontend" rmdir /s /q "frontend"
if exist "updater-off.json" del /q "updater-off.json"
echo ✅ Cleaned
call :cleanup
REM ── 6. Résultats ───────────────────────────────────────────────
echo [6/6] Binaries generated:
@@ -98,3 +189,20 @@ dir /b "%OUTDIR%\bundle\msi\*.msi" 2>nul
echo.
echo ✅ Done! Installers generated in: %OUTDIR%\bundle\
endlocal
exit /b 0
:cleanup
REM ── 5. Nettoyer les dossiers stagés ───────────────────────────
echo [5/6] Cleaning up staged dirs...
if exist "backend" rmdir /s /q "backend"
if exist "frontend" rmdir /s /q "frontend"
if exist "updater-off.json" del /q "updater-off.json"
echo ✅ Cleaned
goto :eof
:fail
echo.
echo ❌ Build failed - see messages above.
call :cleanup
endlocal
exit /b 1
File diff suppressed because one or more lines are too long
+3
View File
@@ -16,10 +16,13 @@ commands.allow = [
"get_backend_url",
"get_version",
"get_config",
"get_desktop_settings",
"set_desktop_environment",
"save_vault_path",
"get_vault_path",
"get_wizard_state",
"complete_wizard",
"open_external_url",
"pick_vault_folder",
"pick_folder",
"get_system_theme",
+183
View File
@@ -84,6 +84,11 @@ struct AppConfig {
/// field existed) parseable instead of falling back to a full reset.
#[serde(default)]
wizard_done: bool,
/// Environnement central choisi (#230) : `"prod"` (og.dracodev.net) ou
/// `"dev"` (og-dev.dracodev.net). `#[serde(default)]` = prod pour les
/// configs existantes ; normalisé à la lecture (`environment_key`).
#[serde(default)]
environment: Option<String>,
}
impl Default for AppConfig {
@@ -97,10 +102,72 @@ impl Default for AppConfig {
window_width: Some(1200.0),
window_height: Some(800.0),
wizard_done: false,
environment: Some(ENV_PROD.to_string()),
}
}
}
// ── Environnement central (#230) ────────────────────────────────────────────
// Le desktop peut viser la production (og.dracodev.net) ou le développement
// (og-dev.dracodev.net). Le shell n'injecte que des variables d'environnement
// dans le backend embarqué : l'application web Docker (qui lit son propre
// `.env`) n'est jamais concernée.
const ENV_PROD: &str = "prod";
const ENV_DEV: &str = "dev";
/// Normalise la valeur stockée : tout ce qui n'est pas `"dev"` vaut `"prod"`.
fn environment_key(value: Option<&str>) -> &'static str {
match value.map(|v| v.trim().to_ascii_lowercase()).as_deref() {
Some(ENV_DEV) => ENV_DEV,
_ => ENV_PROD,
}
}
fn config_environment(config: &AppConfig) -> &'static str {
environment_key(config.environment.as_deref())
}
/// URLs publiques (agent, site central ObsiGate) de l'environnement choisi.
/// L'agent suffit à dériver les applications sœurs et le Hub en `-dev`
/// (backend/draco_config.py, BUG-120) ; les deux sont posées explicitement.
fn environment_urls(env: &str) -> (&'static str, &'static str) {
if env == ENV_DEV {
("https://agent-dev.dracodev.net", "https://og-dev.dracodev.net")
} else {
("https://agent.dracodev.net", "https://og.dracodev.net")
}
}
/// Mot de passe du compte admin local créé au tout premier lancement du
/// desktop. Le backend n'écoute que sur 127.0.0.1 : ce compte est un secours
/// local (aucun terminal pour lire le mot de passe aléatoire), pas une
/// exposition réseau. Le compte central peut aussi déverrouiller cet admin.
/// À changer depuis Réglages → Profil après la première connexion.
pub const DEFAULT_DESKTOP_ADMIN_USER: &str = "admin";
pub const DEFAULT_DESKTOP_ADMIN_PASSWORD: &str = "chab30";
/// Variables injectées dans le backend embarqué (jamais dans le web Docker).
fn desktop_env_vars(env: &str) -> Vec<(&'static str, String)> {
let (agent, obsigate) = environment_urls(env);
vec![
("OBSIGATE_DESKTOP", "1".to_string()),
("OBSIGATE_DESKTOP_SSO", "1".to_string()),
("OBSIGATE_DESKTOP_ENV", env.to_string()),
("OBSIGATE_ADMIN_USER", DEFAULT_DESKTOP_ADMIN_USER.to_string()),
("OBSIGATE_ADMIN_PASSWORD", DEFAULT_DESKTOP_ADMIN_PASSWORD.to_string()),
("DRACO_AGENT_URL", agent.to_string()),
("DRACO_OBSIGATE_URL", obsigate.to_string()),
]
}
#[derive(Debug, Serialize, Clone)]
struct DesktopSettings {
environment: String,
agent_url: String,
central_url: String,
}
// ── Helpers ─────────────────────────────────────────────────────────────────
fn app_data_dir() -> PathBuf {
@@ -243,6 +310,11 @@ fn spawn_backend(exe_dir: &PathBuf) -> Result<Child, String> {
cmd.env(format!("DIR_{}_PATH", n), &dir.path);
}
// #230 : environnement central prod/dev (SSO, barre inter-apps, Hub).
for (key, value) in desktop_env_vars(config_environment(&config)) {
cmd.env(key, value);
}
let port = pick_free_port();
BACKEND_PORT.store(port, Ordering::Relaxed);
@@ -322,6 +394,42 @@ fn get_config() -> AppConfig {
load_config()
}
/// Environnement central + URLs résolues (interface Configuration / wizard).
#[tauri::command]
fn get_desktop_settings() -> DesktopSettings {
let config = load_config();
let env = config_environment(&config);
let (agent, central) = environment_urls(env);
DesktopSettings {
environment: env.to_string(),
agent_url: agent.to_string(),
central_url: central.to_string(),
}
}
/// Enregistre l'environnement central (#230). Le frontend redémarre ensuite
/// le backend pour que les variables `DRACO_*` soient réinjectées.
#[tauri::command]
fn set_desktop_environment(environment: String) -> Result<DesktopSettings, String> {
let normalized = environment_key(Some(&environment));
if normalized != environment.trim().to_ascii_lowercase() {
return Err(format!(
"Environnement inconnu '{}' (attendu : prod ou dev)",
environment
));
}
let mut config = load_config();
config.environment = Some(normalized.to_string());
save_config(&config);
let (agent, central) = environment_urls(normalized);
info!("Desktop environment set to {}", normalized);
Ok(DesktopSettings {
environment: normalized.to_string(),
agent_url: agent.to_string(),
central_url: central.to_string(),
})
}
#[tauri::command]
fn save_vault_path(path: String) -> Result<(), String> {
let mut config = load_config();
@@ -371,6 +479,26 @@ fn get_wizard_state() -> bool {
load_config().wizard_done
}
/// Ouvre l'URL d'approbation du central dans le navigateur système (#230).
/// Seuls les hôtes `https://*.dracodev.net` sont acceptés.
#[allow(deprecated)] // tauri-plugin-shell::open est déprécié au profit d'opener ;
// le plugin shell est déjà embarqué et ACL-restreint.
#[tauri::command]
fn open_external_url(app: tauri::AppHandle, url: String) -> Result<bool, String> {
let parsed = tauri::Url::parse(&url).map_err(|e| format!("URL invalide : {}", e))?;
let host = parsed.host_str().unwrap_or("").to_ascii_lowercase();
if parsed.scheme() != "https"
|| !(host == "dracodev.net" || host.ends_with(".dracodev.net"))
{
return Err("URL externe refusée (https *.dracodev.net attendu)".to_string());
}
use tauri_plugin_shell::ShellExt;
app.shell()
.open(parsed.to_string(), None)
.map_err(|e| e.to_string())?;
Ok(true)
}
#[tauri::command]
fn complete_wizard() -> Result<(), String> {
let mut config = load_config();
@@ -642,10 +770,13 @@ fn main() {
get_backend_url,
get_version,
get_config,
get_desktop_settings,
set_desktop_environment,
save_vault_path,
get_vault_path,
get_wizard_state,
complete_wizard,
open_external_url,
pick_vault_folder,
pick_folder,
get_system_theme,
@@ -1001,6 +1132,7 @@ mod tests {
assert_eq!(c.window_width, Some(1200.0));
assert_eq!(c.window_height, Some(800.0));
assert!(!c.wizard_done);
assert_eq!(c.environment.as_deref(), Some(ENV_PROD));
}
#[test]
@@ -1017,6 +1149,7 @@ mod tests {
window_width: Some(1400.0),
window_height: Some(900.0),
wizard_done: true,
environment: Some(ENV_DEV.into()),
};
let loaded = roundtrip_config(&c);
assert_eq!(loaded.vault_path, Some("/test/vault".into()));
@@ -1026,6 +1159,7 @@ mod tests {
assert_eq!(loaded.dirs.len(), 1);
assert_eq!(loaded.window_x, Some(100.0));
assert!(loaded.wizard_done);
assert_eq!(loaded.environment.as_deref(), Some(ENV_DEV));
}
#[test]
@@ -1054,6 +1188,55 @@ mod tests {
assert!(roundtrip_config(&c).wizard_done);
}
#[test]
fn test_environment_normalization() {
assert_eq!(environment_key(None), ENV_PROD);
assert_eq!(environment_key(Some("prod")), ENV_PROD);
assert_eq!(environment_key(Some(" DEV ")), ENV_DEV);
assert_eq!(environment_key(Some("staging")), ENV_PROD);
}
#[test]
fn test_environment_urls() {
assert_eq!(
environment_urls(ENV_PROD),
("https://agent.dracodev.net", "https://og.dracodev.net")
);
assert_eq!(
environment_urls(ENV_DEV),
("https://agent-dev.dracodev.net", "https://og-dev.dracodev.net")
);
}
#[test]
fn test_desktop_env_vars() {
let vars = desktop_env_vars(ENV_DEV);
let get = |k: &str| vars.iter().find(|(name, _)| *name == k).map(|(_, v)| v.as_str());
assert_eq!(get("OBSIGATE_DESKTOP"), Some("1"));
assert_eq!(get("OBSIGATE_DESKTOP_SSO"), Some("1"));
assert_eq!(get("OBSIGATE_DESKTOP_ENV"), Some(ENV_DEV));
assert_eq!(get("OBSIGATE_ADMIN_USER"), Some(DEFAULT_DESKTOP_ADMIN_USER));
assert_eq!(get("OBSIGATE_ADMIN_PASSWORD"), Some(DEFAULT_DESKTOP_ADMIN_PASSWORD));
assert_eq!(get("DRACO_AGENT_URL"), Some("https://agent-dev.dracodev.net"));
assert_eq!(get("DRACO_OBSIGATE_URL"), Some("https://og-dev.dracodev.net"));
}
#[test]
fn test_environment_missing_in_legacy_config_is_prod() {
let json = r#"{
"vault_path": null,
"vaults": [],
"dirs": [],
"window_x": null,
"window_y": null,
"window_width": 1000.0,
"window_height": 700.0,
"wizard_done": true
}"#;
let c: AppConfig = serde_json::from_str(json).unwrap();
assert_eq!(config_environment(&c), ENV_PROD);
}
#[test]
fn test_config_empty_json() {
// serde requires vaults/dirs fields — missing fields use unwrap_or_default
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/nicedoc/obsigate/main/desktop/tauri.conf.schema.json",
"productName": "ObsiGate",
"version": "2.87.3",
"version": "2.88.0",
"identifier": "com.obsigate.desktop",
"build": {
"frontendDist": "../frontend",