feat: desktop — connexion compte central + environnement prod/dev (#230)
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:
+17
-1
@@ -6,7 +6,7 @@ Format basé sur [Keep a Changelog](https://keepachangelog.com/fr/1.1.0/),
|
||||
et [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
> **En cours de développement** : les changements à venir sont listés dans la section
|
||||
> [Unreleased](#unreleased). La dernière version livrée est **2.87.3**.
|
||||
> [Unreleased](#unreleased). La dernière version livrée est **2.88.0**.
|
||||
|
||||
---
|
||||
|
||||
@@ -14,6 +14,22 @@ et [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
---
|
||||
|
||||
## [2.88.0] — 2026-11-20
|
||||
|
||||
### Ajouté
|
||||
|
||||
- **#230 — Desktop : connexion avec un compte central et choix de l'environnement (prod/dev)** : l'application desktop peut désormais être déverrouillée par le compte central dracodev, sans saisir le mot de passe central dans la fenêtre. Le shell Tauri démarre une **liaison d'appareil** sur le site central choisi (`og.dracodev.net` ou `og-dev.dracodev.net`) via le flux `/api/v1/liaison` déjà en place ; l'utilisateur approuve dans son navigateur, le backend embarqué valide le jeton draco auprès du central (`/api/auth/me`) puis ouvre la session de **l'admin local par défaut**. Le login local reste disponible (admin/chab30 à la création initiale, modifiable ensuite). Sélecteur d'environnement dans la Configuration et le premier lancement, persisté dans `%APPDATA%\ObsiGate\config.json` et injecté au seul backend desktop (`DRACO_AGENT_URL` / `DRACO_OBSIGATE_URL`, sœurs et Hub `-dev` dérivés). Aucun impact sur l'application web Docker : les routes `/api/desktop/sso/*` répondent 404 hors desktop et l'UI est conditionnée par `isTauriEnv()`. Fiche : `docs/features/desktop-sso-environnement-230.md`. Tests : `tests/test_desktop_sso.py` (9), 32 tests Rust, `desktop.test.mjs` (30), garde-fous UI.
|
||||
|
||||
### Corrigé
|
||||
|
||||
- **BUG-127 — la page `/liaison` ne reprenait pas après le login central** : le lien « Se connecter » de la page d'approbation renvoie vers elle-même (`return_to` même hôte), mais `_honorReturnTo()` ignorait tous les retours de l'hôte courant — après connexion, l'utilisateur arrivait sur l'accueil et la liaison desktop restait en attente. Le retour est honoré pour `/liaison` (et seulement ce chemin même-hôte, pas de boucle) ; les autres retours SSO sont inchangés. Tests : `tests/test_draco_barre.py::test_retour_liaison_meme_hote_230`.
|
||||
|
||||
- **BUG-126 — l'exe desktop s'ouvrait sans CSS (backend Python jamais démarré)** : le build Windows pouvait produire un `python311._pth` incomplet (sans `python311.zip` ni `.`), l'embed Python ne trouvait plus sa bibliothèque standard (`ModuleNotFoundError: No module named 'encodings'`), le backend mourait avant le premier appel et la fenêtre restait sur le HTML embarqué par Tauri — dont les liens `/static/style.css` ne résolvent pas, d'où l'interface non stylée. `build-windows.bat` écrit désormais ce fichier explicitement (`python311.zip`, `.`, `import site`, `..`), vérifie chaque étape (téléchargement, extraction, pip, imports) et échoue franchement au lieu de continuer sur un runtime cassé. Le runtime complet (`python-embed`, `backend`, `frontend`) est copié à côté de l'exécutable, comme sous Linux ; le script s'exécute depuis son propre dossier et n'arrête plus que le python embarqué. Garde-fou de non-régression : `tests/test_desktop_build_scripts.py` (5 tests, contenu du `_pth`, copie du runtime, `--ci`, signature opt-in).
|
||||
- **BUG-126 — `build-windows.bat` demandait deux fois un mot de passe** : la clé updater protégée déclenchait une invite interactive de Tauri CLI (et une seconde via le repli NSIS). La signature `.sig` est maintenant opt-in (`TAURI_SIGNING_PRIVATE_KEY_PASSWORD`) ; sans mot de passe, le build continue sans `.sig` et sans invite (`--ci`). Même logique appliquée à `build-linux.sh`.
|
||||
- **Build Windows — une instance encore ouverte verrouillait l'exécutable** (`Access is denied`, échec de compilation) : le script ferme désormais `obsigate-desktop.exe` avant de compiler (étape 0), en plus du backend embarqué.
|
||||
|
||||
---
|
||||
|
||||
## [2.87.3] — 2026-11-17
|
||||
|
||||
- **Docker — retrait du conteneur Ollama des fichiers compose** : le service `ollama` (`obsigate-ollama` en production, `obsigate-test-ollama` en test) est supprimé de `docker-compose.yml`, `docker-compose.test-win.yml` et `docker-compose.test-linux.yml`, avec son volume `ollama_data` et les variables `OLLAMA_BASE_URL` / `OLLAMA_MODEL` du service `obsigate` — cette portion de la solution n'est plus utilisée (le fournisseur IA par défaut est DeepSeek ; le fournisseur `ollama` de `backend/ai.py` reste disponible et peut être réactivé via le `.env`). Bénéfice immédiat : plus de conflit possible sur le port 11434 avec un Ollama installé en natif sur le poste Windows.
|
||||
|
||||
+14
-10
@@ -4,7 +4,7 @@
|
||||
|
||||
**Porte d'entrée web ultra-léger pour vos vaults Obsidian** — Accédez, naviguez et recherchez dans toutes vos notes Obsidian depuis n'importe quel appareil via une interface web moderne et responsive.
|
||||
|
||||
[]()
|
||||
[]()
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](https://www.docker.com/)
|
||||
[](https://www.python.org/)
|
||||
@@ -459,6 +459,8 @@ ObsiGate Desktop est une application native construite avec [Tauri](https://taur
|
||||
| Tray icon | ❌ | ✅ Barre des tâches |
|
||||
| Auto-update | ❌ | ✅ Vérifie les releases Gitea |
|
||||
| Mode hors-ligne | Limité | Complet (backend local) |
|
||||
| Connexion compte central | ✅ | ✅ Liaison d'appareil (admin local déverrouillé) |
|
||||
| Environnement central (prod/dev) | `.env` serveur | ✅ Configuration + premier lancement |
|
||||
|
||||
### Téléchargement (binaires pré-buildés)
|
||||
|
||||
@@ -485,8 +487,9 @@ REM Windows : double-cliquer sur ObsiGate_2.0.0_x64.msi (ou le setup NSIS)
|
||||
1. **Lancez l'application** depuis le menu ou la ligne de commande
|
||||
2. Le backend Python démarre automatiquement sur `127.0.0.1:17890` (splash « Démarrage… » pendant le boot)
|
||||
3. La fenêtre s'ouvre et charge l'interface ObsiGate
|
||||
4. **Premier lancement** : sélectionnez le dossier de vos vaults Obsidian via le sélecteur natif
|
||||
5. Pour fermer : icône tray → Quitter (arrêt propre du backend)
|
||||
4. **Premier lancement** : choisissez l'environnement central (prod/dev) et sélectionnez le dossier de vos vaults Obsidian via le sélecteur natif
|
||||
5. **Connectez-vous** avec l'admin local (`admin` / `chab30` à la création) ou avec votre compte central (approbation dans le navigateur)
|
||||
6. Pour fermer : icône tray → Quitter (arrêt propre du backend)
|
||||
|
||||
### Build depuis les sources
|
||||
|
||||
@@ -519,12 +522,13 @@ build-windows.bat
|
||||
|
||||
Étapes du script :
|
||||
|
||||
1. Tue les processus Python résiduels (`taskkill /F /IM python.exe`)
|
||||
2. Télécharge **Python 3.11 embed** (python.org) → `desktop\python-embed\` + activation de pip (`python311._pth`)
|
||||
3. `pip install -r ..\backend\requirements.txt` dans l'embed
|
||||
1. S'exécute depuis son propre dossier (sûr même appelé via `desktop\build-windows.bat`) et n'arrête que le backend embarqué (`*\python-embed\python.exe`)
|
||||
2. Télécharge **Python 3.11 embed** (python.org) → `desktop\python-embed\` et écrit un `python311._pth` complet (stdlib `python311.zip`, `.`, `import site`, `..` pour `import backend`)
|
||||
3. `pip install -r ..\backend\requirements.txt` dans l'embed, puis un contrôle (`import encodings, uvicorn, fastapi, pyotp`)
|
||||
4. **Staging** : copie `..\backend` et `..\frontend` dans `desktop\`
|
||||
5. `cargo tauri build --target x86_64-pc-windows-msvc --bundles nsis`
|
||||
6. Copie `python-embed` à côté de l'exécutable (`target\x86_64-pc-windows-msvc\release\`) pour le mode dev local
|
||||
5. `cargo tauri build --ci --target x86_64-pc-windows-msvc --bundles nsis,msi`
|
||||
Les fichiers `.sig` de l'updater ne sont produits que si `TAURI_SIGNING_PRIVATE_KEY_PASSWORD` est défini — aucune invite de mot de passe.
|
||||
6. Copie le runtime (`python-embed`, `backend`, `frontend`) à côté de l'exécutable (`target\x86_64-pc-windows-msvc\release\`) pour le mode dev local
|
||||
7. Nettoie les dossiers stagés
|
||||
|
||||
→ **Artefact :** `desktop\target\x86_64-pc-windows-msvc\release\bundle\nsis\ObsiGate_2.0.0_x64-setup.exe`
|
||||
@@ -977,8 +981,8 @@ Ce projet est sous licence **MIT** — voir le fichier [LICENSE](LICENSE) pour l
|
||||
|
||||
## 📝 Changelog
|
||||
|
||||
Consultez le [CHANGELOG.md](./CHANGELOG.md) pour l'historique complet de toutes les versions (v1.0.0 → v2.87.3).
|
||||
Consultez le [CHANGELOG.md](./CHANGELOG.md) pour l'historique complet de toutes les versions (v1.0.0 → v2.88.0).
|
||||
|
||||
---
|
||||
|
||||
*Projet : ObsiGate | Version : 2.87.3 | Dernière mise à jour : Septembre 2026*
|
||||
*Projet : ObsiGate | Version : 2.88.0 | Dernière mise à jour : Septembre 2026*
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
**Ultra-light web gateway for your Obsidian vaults** — Access, browse, and search all your Obsidian notes from any device via a modern, responsive web interface.
|
||||
|
||||
[]()
|
||||
[]()
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](https://www.docker.com/)
|
||||
[](https://www.python.org/)
|
||||
@@ -572,6 +572,8 @@ ObsiGate Desktop is a native application built with [Tauri](https://tauri.app/)
|
||||
| Tray icon | ❌ | ✅ Taskbar |
|
||||
| Auto-update | ❌ | ✅ Checks Gitea releases |
|
||||
| Offline mode | Limited | Full (local backend) |
|
||||
| Central account sign-in | ✅ | ✅ Device link (local admin unlocked) |
|
||||
| Central environment (prod/dev) | Server-side `.env` | ✅ Configuration + first run |
|
||||
|
||||
### Download (Pre-built Binaries)
|
||||
|
||||
@@ -606,8 +608,9 @@ chmod +x ObsiGate_2.0.0_amd64.AppImage
|
||||
1. **Launch the application** from the menu or command line
|
||||
2. The Python backend starts automatically on `127.0.0.1:17890`
|
||||
3. The window opens and loads the ObsiGate interface
|
||||
4. **First launch** : select your Obsidian vaults folder via the native picker
|
||||
5. To close : tray icon → Quit (clean backend shutdown)
|
||||
4. **First launch** : choose the central environment (prod/dev) and select your Obsidian vaults folder via the native picker
|
||||
5. **Sign in** with the local admin (`admin` / `chab30` at creation) or with your central account (approval in your browser)
|
||||
6. To close : tray icon → Quit (clean backend shutdown)
|
||||
|
||||
### Build from Source
|
||||
|
||||
@@ -640,12 +643,13 @@ build-windows.bat
|
||||
|
||||
Script steps:
|
||||
|
||||
1. Kills residual Python processes (`taskkill /F /IM python.exe`)
|
||||
2. Downloads **Python 3.11 embed** (python.org) → `desktop\python-embed\` + enables pip (`python311._pth`)
|
||||
3. `pip install -r ..\backend\requirements.txt` in the embed
|
||||
1. Runs from its own folder (safe even if invoked as `desktop\build-windows.bat`) and stops only the embedded backend (`*\python-embed\python.exe`)
|
||||
2. Downloads **Python 3.11 embed** (python.org) → `desktop\python-embed\` and writes a complete `python311._pth` (stdlib `python311.zip`, `.`, `import site`, `..` for `import backend`)
|
||||
3. `pip install -r ..\backend\requirements.txt` in the embed, then a sanity check (`import encodings, uvicorn, fastapi, pyotp`)
|
||||
4. **Staging** : copies `..\backend` and `..\frontend` to `desktop\`
|
||||
5. `cargo tauri build --target x86_64-pc-windows-msvc --bundles nsis`
|
||||
6. Copies `python-embed` next to the executable (`target\x86_64-pc-windows-msvc\release\`) for local dev mode
|
||||
5. `cargo tauri build --ci --target x86_64-pc-windows-msvc --bundles nsis,msi`
|
||||
Updater `.sig` files are produced only when `TAURI_SIGNING_PRIVATE_KEY_PASSWORD` is set — no interactive password prompt.
|
||||
6. Copies the runtime (`python-embed`, `backend`, `frontend`) next to the executable (`target\x86_64-pc-windows-msvc\release\`) for local dev mode
|
||||
7. Cleans the staged folders
|
||||
|
||||
→ **Artifact :** `desktop\target\x86_64-pc-windows-msvc\release\bundle\nsis\ObsiGate_2.0.0_x64-setup.exe`
|
||||
@@ -1152,8 +1156,8 @@ This project is licensed under the **MIT License** - see the [LICENSE](LICENSE)
|
||||
|
||||
## 📝 Changelog
|
||||
|
||||
See [CHANGELOG.md](./CHANGELOG.md) for the complete version history (v1.0.0 → v2.87.3).
|
||||
See [CHANGELOG.md](./CHANGELOG.md) for the complete version history (v1.0.0 → v2.88.0).
|
||||
|
||||
---
|
||||
|
||||
*Project: ObsiGate | Version: 2.87.3 | Last updated: September 2026*
|
||||
*Project: ObsiGate | Version: 2.88.0 | Last updated: September 2026*
|
||||
|
||||
@@ -559,6 +559,7 @@ from backend.routers.comptes_machine import router as comptes_machine_router
|
||||
from backend.routers.config import _load_config
|
||||
from backend.routers.config import router as config_router
|
||||
from backend.routers.conflicts import router as conflicts_router
|
||||
from backend.routers.desktop_sso import router as desktop_sso_router
|
||||
from backend.routers.duplicates import router as duplicates_router
|
||||
from backend.routers.external_refs import router as external_refs_router
|
||||
from backend.routers.file_chat import router as file_chat_router
|
||||
@@ -587,6 +588,7 @@ app.include_router(history_router) # ROADMAP #85 T8 — History
|
||||
app.include_router(external_refs_router) # Fusion #215 — Références croisées (ACC-1.3)
|
||||
app.include_router(sso_router) # Fusion #216 — Émettrice SSO draco_session (ACC-3.1)
|
||||
app.include_router(liaison_router) # #75 — Liaison d'appareil (jeton draco)
|
||||
app.include_router(desktop_sso_router) # #230 — Desktop : compte central (404 hors desktop)
|
||||
app.include_router(realtime_router) # ROADMAP #85 T9 — SSE + collab WS
|
||||
app.include_router(search_router) # ROADMAP #85 T5 — Search
|
||||
app.include_router(backups_router) # ROADMAP #85 T4 — Backups
|
||||
|
||||
@@ -0,0 +1,290 @@
|
||||
# backend/routers/desktop_sso.py
|
||||
# Desktop (Tauri) — connexion avec un compte central dracodev (#230).
|
||||
#
|
||||
# L'application desktop sert son propre backend sur http://127.0.0.1 : le
|
||||
# cookie ``draco_session`` du site central (Domain=.dracodev.net) ne lui
|
||||
# parvient jamais. Ce module fait le pont **côté serveur desktop** :
|
||||
#
|
||||
# 1. POST /api/desktop/sso/start -> démarre une liaison d'appareil sur le
|
||||
# site central choisi (og / og-dev) via le flux existant
|
||||
# ``POST {central}/api/v1/liaison`` ;
|
||||
# 2. l'utilisateur approuve la liaison dans son navigateur (page publique
|
||||
# ``/liaison`` du central) ;
|
||||
# 3. POST /api/desktop/sso/poll -> sonde la liaison, récupère le jeton
|
||||
# draco (livré une seule fois), le valide auprès du central
|
||||
# (``GET {central}/api/auth/me`` avec le cookie draco) puis ouvre la
|
||||
# session de **l'admin local par défaut** (décision : le compte central
|
||||
# prouve l'identité, le desktop reste mono-utilisateur).
|
||||
#
|
||||
# Inerte hors desktop : toutes les routes répondent 404 tant que
|
||||
# ``OBSIGATE_DESKTOP_SSO`` n'est pas activé (le shell Tauri le pose sur le
|
||||
# backend embarqué ; l'application web Docker ne le définit jamais). Le
|
||||
# comportement de l'application web est donc inchangé.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import socket
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import httpx
|
||||
from fastapi import APIRouter, HTTPException, Request, Response
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from backend import draco_config
|
||||
|
||||
router = APIRouter(prefix="/api/desktop/sso", tags=["Desktop SSO"],
|
||||
include_in_schema=False)
|
||||
|
||||
ENV_FLAG = "OBSIGATE_DESKTOP_SSO"
|
||||
CENTRAL_TIMEOUT_SECONDS = 10.0
|
||||
#: Hôtes centraux autorisés : les deux environnements proposés par le
|
||||
#: sélecteur desktop. Toute autre valeur est refusée (pas de SSRF arbitraire).
|
||||
CENTRAL_HOSTS = {"og.dracodev.net", "og-dev.dracodev.net"}
|
||||
|
||||
|
||||
def enabled() -> bool:
|
||||
"""Vrai lorsque le backend tourne dans le shell desktop."""
|
||||
return os.environ.get(ENV_FLAG, "").lower() in ("1", "true", "yes", "on")
|
||||
|
||||
|
||||
def _require_enabled() -> None:
|
||||
if not enabled():
|
||||
raise HTTPException(status_code=404, detail="Not Found")
|
||||
|
||||
|
||||
def _require_loopback_origin(request: Request) -> None:
|
||||
"""Refuse une requête navigateur d'une origine non locale.
|
||||
|
||||
Le backend n'écoute que sur 127.0.0.1, mais une page web ouverte dans le
|
||||
navigateur pourrait émettre un POST vers localhost. Les requêtes du
|
||||
webview desktop portent ``Origin: http://127.0.0.1:<port>`` ; toute autre
|
||||
origine est rejetée (une requête sans Origin — curl, test — reste permise).
|
||||
"""
|
||||
origin = (request.headers.get("origin") or "").strip()
|
||||
if not origin:
|
||||
return
|
||||
parsed = urlparse(origin)
|
||||
host = (parsed.hostname or "").lower()
|
||||
if parsed.scheme not in ("http", "https") or host not in (
|
||||
"127.0.0.1", "localhost", "::1",
|
||||
):
|
||||
raise HTTPException(status_code=403, detail="Origine non autorisée.")
|
||||
|
||||
|
||||
def central_url() -> str:
|
||||
"""Base du site central choisi (prod/dev), validée.
|
||||
|
||||
Priorité ``DRACO_OBSIGATE_URL`` puis la résolution d'écosystème de
|
||||
:mod:`backend.draco_config` (qui dérive ``-dev`` depuis l'agent). Seuls
|
||||
les deux hôtes centraux officiels sont acceptés.
|
||||
"""
|
||||
url = (os.environ.get("DRACO_OBSIGATE_URL", "").strip()
|
||||
or draco_config.app_url("obsigate")).rstrip("/")
|
||||
parsed = urlparse(url)
|
||||
host = (parsed.hostname or "").lower()
|
||||
if parsed.scheme != "https" or host not in CENTRAL_HOSTS:
|
||||
raise HTTPException(
|
||||
status_code=503,
|
||||
detail="Site central non configuré pour ObsiGate Desktop.",
|
||||
)
|
||||
return url
|
||||
|
||||
|
||||
def _device_name() -> str:
|
||||
try:
|
||||
host = socket.gethostname().strip()
|
||||
except OSError:
|
||||
host = ""
|
||||
return f"ObsiGate Desktop ({host})" if host else "ObsiGate Desktop"
|
||||
|
||||
|
||||
def _central_post(path: str, payload: dict) -> dict:
|
||||
"""POST JSON vers le central, erreurs traduites en HTTPException."""
|
||||
try:
|
||||
with httpx.Client(timeout=CENTRAL_TIMEOUT_SECONDS) as client:
|
||||
resp = client.post(central_url() + path, json=payload)
|
||||
except httpx.HTTPError as exc:
|
||||
raise HTTPException(
|
||||
status_code=502,
|
||||
detail="Site central injoignable — vérifiez l'environnement choisi "
|
||||
"et votre connexion.",
|
||||
) from exc
|
||||
if resp.status_code >= 400:
|
||||
detail = ""
|
||||
try:
|
||||
detail = str(resp.json().get("detail", ""))
|
||||
except (ValueError, AttributeError):
|
||||
detail = ""
|
||||
raise HTTPException(
|
||||
status_code=resp.status_code if 400 <= resp.status_code < 500 else 502,
|
||||
detail=detail or "Le site central a refusé la demande.",
|
||||
)
|
||||
try:
|
||||
return resp.json()
|
||||
except ValueError as exc:
|
||||
raise HTTPException(
|
||||
status_code=502,
|
||||
detail="Réponse invalide du site central.",
|
||||
) from exc
|
||||
|
||||
|
||||
def _central_me(token: str) -> dict:
|
||||
"""Valide le jeton draco auprès du central (cookie ``draco_session``).
|
||||
|
||||
Le jeton n'est jamais journalisé : il sert uniquement à cette requête
|
||||
serveur-à-serveur. Un jeton révoqué, expiré, ou dont le rôle Hub est
|
||||
« aucun » est refusé par le central (401/403), message relayé tel quel.
|
||||
"""
|
||||
try:
|
||||
with httpx.Client(timeout=CENTRAL_TIMEOUT_SECONDS) as client:
|
||||
resp = client.get(
|
||||
central_url() + "/api/auth/me",
|
||||
cookies={"draco_session": token},
|
||||
)
|
||||
except httpx.HTTPError as exc:
|
||||
raise HTTPException(
|
||||
status_code=502,
|
||||
detail="Impossible de vérifier le compte central (site injoignable).",
|
||||
) from exc
|
||||
if resp.status_code in (401, 403):
|
||||
detail = ""
|
||||
try:
|
||||
detail = str(resp.json().get("detail", ""))
|
||||
except (ValueError, AttributeError):
|
||||
detail = ""
|
||||
raise HTTPException(
|
||||
status_code=resp.status_code,
|
||||
detail=detail or "Compte central refusé.",
|
||||
)
|
||||
if resp.status_code != 200:
|
||||
raise HTTPException(
|
||||
status_code=502,
|
||||
detail="Le site central n'a pas pu valider le compte.",
|
||||
)
|
||||
try:
|
||||
return resp.json()
|
||||
except ValueError as exc:
|
||||
raise HTTPException(
|
||||
status_code=502,
|
||||
detail="Réponse invalide du site central.",
|
||||
) from exc
|
||||
|
||||
|
||||
def _local_admin() -> dict:
|
||||
"""Compte admin local par défaut (décision #230).
|
||||
|
||||
Priorité à ``OBSIGATE_ADMIN_USER`` s'il désigne un admin actif, puis
|
||||
``admin``, puis le premier admin actif. Aucun compte créé ici : la
|
||||
connexion centralisée **ouvre** l'admin local existant.
|
||||
"""
|
||||
from backend.auth.user_store import get_all_users, get_user
|
||||
|
||||
preferred = os.environ.get("OBSIGATE_ADMIN_USER", "admin")
|
||||
candidate = get_user(preferred)
|
||||
if candidate and candidate.get("role") == "admin" and candidate.get("active"):
|
||||
return candidate
|
||||
|
||||
admins = [u for u in get_all_users()
|
||||
if u.get("role") == "admin" and u.get("active")]
|
||||
if not admins:
|
||||
raise HTTPException(
|
||||
status_code=500,
|
||||
detail="Aucun compte administrateur local actif : connectez-vous "
|
||||
"d'abord avec le mot de passe admin, ou créez un admin.",
|
||||
)
|
||||
for admin in admins:
|
||||
if admin.get("username") == "admin":
|
||||
return get_user("admin") # type: ignore[return-value]
|
||||
return get_user(admins[0]["username"]) # type: ignore[return-value]
|
||||
|
||||
|
||||
class PollIn(BaseModel):
|
||||
"""Sondage d'une demande de liaison + activation de la session locale."""
|
||||
|
||||
demande_id: str = Field(min_length=1)
|
||||
code_appareil: str = Field(min_length=1)
|
||||
remember_me: bool = True
|
||||
|
||||
|
||||
@router.get("/status")
|
||||
async def desktop_sso_status() -> dict:
|
||||
"""État du pont pour l'interface (desktop uniquement)."""
|
||||
_require_enabled()
|
||||
try:
|
||||
url = central_url()
|
||||
except HTTPException:
|
||||
url = ""
|
||||
return {
|
||||
"enabled": True,
|
||||
"environment": os.environ.get("OBSIGATE_DESKTOP_ENV", "prod"),
|
||||
"central_url": url,
|
||||
}
|
||||
|
||||
|
||||
@router.post("/start")
|
||||
async def desktop_sso_start(request: Request) -> dict:
|
||||
"""Démarre une liaison d'appareil sur le site central choisi."""
|
||||
_require_enabled()
|
||||
_require_loopback_origin(request)
|
||||
result = _central_post(
|
||||
"/api/v1/liaison",
|
||||
{"nom": _device_name(), "type": "desktop"},
|
||||
)
|
||||
# Le central construit ``url_liaison_absolue`` depuis ``request.base_url`` :
|
||||
# derrière un reverse proxy qui ne transmet pas X-Forwarded-Proto, il peut
|
||||
# renvoyer ``http://og...``. On reconstruit toujours l'URL depuis le site
|
||||
# central configuré (https) et le chemin relatif — l'ouverture navigateur
|
||||
# exige https://*.dracodev.net.
|
||||
rel = result.get("url_liaison")
|
||||
if isinstance(rel, str) and rel.startswith("/"):
|
||||
result["url_liaison_absolue"] = central_url() + rel
|
||||
return result
|
||||
|
||||
|
||||
@router.post("/poll")
|
||||
async def desktop_sso_poll(body: PollIn, request: Request,
|
||||
response: Response) -> dict:
|
||||
"""Sonde la liaison ; si approuvée, ouvre la session de l'admin local.
|
||||
|
||||
Retourne ``{"statut": "en_attente"}`` tant que l'utilisateur n'a pas
|
||||
approuvé, puis la même charge que ``POST /api/auth/login`` (jeton local
|
||||
+ cookie refresh) avec ``statut = "approuvee"``.
|
||||
"""
|
||||
_require_enabled()
|
||||
_require_loopback_origin(request)
|
||||
result = _central_post(
|
||||
"/api/v1/liaison/sonder",
|
||||
{"demande_id": body.demande_id, "code_appareil": body.code_appareil},
|
||||
)
|
||||
statut = str(result.get("statut", ""))
|
||||
if statut != "approuvee":
|
||||
return {"statut": statut}
|
||||
|
||||
token = result.get("jeton")
|
||||
if not token:
|
||||
raise HTTPException(
|
||||
status_code=502,
|
||||
detail="Le site central n'a pas renvoyé de jeton de session.",
|
||||
)
|
||||
|
||||
central_user = _central_me(str(token))
|
||||
admin = _local_admin()
|
||||
|
||||
# Émission des jetons natifs locaux : mêmes cookies/format que /api/auth/login.
|
||||
from backend.auth.router import _issue_tokens
|
||||
|
||||
payload = _issue_tokens(
|
||||
admin,
|
||||
admin["username"],
|
||||
bool(body.remember_me),
|
||||
response,
|
||||
request,
|
||||
)
|
||||
payload["statut"] = "approuvee"
|
||||
payload["central_user"] = {
|
||||
"username": central_user.get("username"),
|
||||
"display_name": central_user.get("display_name"),
|
||||
"role": central_user.get("role"),
|
||||
}
|
||||
return payload
|
||||
Generated
+1
-1
@@ -2626,7 +2626,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "obsigate-desktop"
|
||||
version = "2.87.3"
|
||||
version = "2.88.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"env_logger",
|
||||
|
||||
+1
-1
@@ -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
@@ -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) :
|
||||
|
||||
@@ -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
@@ -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
@@ -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",
|
||||
|
||||
@@ -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,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",
|
||||
|
||||
@@ -85,26 +85,41 @@ Copiez le contenu de `obsigate-updater.key.pub` dans
|
||||
|
||||
### B. Build local signé
|
||||
|
||||
La clé privée peut être protégée par un mot de passe. Tauri CLI le demande alors
|
||||
de façon **interactive** (et une seconde fois quand le repli NSIS relance le
|
||||
build) : impossible à fournir dans un script non surveillé. Les scripts de build
|
||||
ne signent donc que si le mot de passe est fourni dans l'environnement ; sinon
|
||||
ils désactivent `createUpdaterArtifacts` et n'affichent **aucune invite**.
|
||||
|
||||
```powershell
|
||||
# Windows PowerShell
|
||||
$env:TAURI_SIGNING_PRIVATE_KEY = Get-Content -Raw .\obsigate-updater.key
|
||||
# $env:TAURI_SIGNING_PRIVATE_KEY_PASSWORD = "<mot de passe>" # si la clé en a un
|
||||
cargo tauri build --bundles nsis,msi
|
||||
# Windows — script (tout le reste est automatique)
|
||||
$env:TAURI_SIGNING_PRIVATE_KEY_PASSWORD = "<mot de passe>" # clé protégée
|
||||
cd desktop
|
||||
.\build-windows.bat
|
||||
```
|
||||
|
||||
```powershell
|
||||
# Windows PowerShell — build Tauri direct
|
||||
$env:TAURI_SIGNING_PRIVATE_KEY_PATH = ".\obsigate-updater.key"
|
||||
$env:TAURI_SIGNING_PRIVATE_KEY_PASSWORD = "<mot de passe>"
|
||||
cargo tauri build --ci --bundles nsis,msi
|
||||
```
|
||||
|
||||
```bash
|
||||
# Linux / Bash
|
||||
export TAURI_SIGNING_PRIVATE_KEY="$(cat obsigate-updater.key)"
|
||||
# export TAURI_SIGNING_PRIVATE_KEY_PASSWORD="<mot de passe>"
|
||||
cargo tauri build --bundles appimage,deb
|
||||
export TAURI_SIGNING_PRIVATE_KEY_PATH="obsigate-updater.key"
|
||||
export TAURI_SIGNING_PRIVATE_KEY_PASSWORD="<mot de passe>"
|
||||
cargo tauri build --ci --bundles appimage,deb
|
||||
```
|
||||
|
||||
Le CLI produit des fichiers `.sig` à côté de chaque artefact
|
||||
(`*.exe.sig`, `*.msi.sig`, `*.AppImage.sig`, `*.deb.sig`).
|
||||
|
||||
> Sans clé définie, `createUpdaterArtifacts` est actif et le build échoue : dans
|
||||
> le CI, l'étape désactive automatiquement les artefacts de mise à jour si le
|
||||
> secret est absent.
|
||||
> Sans mot de passe (`TAURI_SIGNING_PRIVATE_KEY_PASSWORD`), les scripts
|
||||
> `build-windows.bat` / `build-linux.sh` construisent sans `.sig` ; le build
|
||||
> direct `cargo tauri build` doit alors passer un `--config` qui met
|
||||
> `createUpdaterArtifacts: false`, sinon il échoue. Dans le CI, l'étape désactive
|
||||
> automatiquement les artefacts de mise à jour si le secret est absent.
|
||||
|
||||
### C. Secrets CI (Gitea)
|
||||
|
||||
|
||||
+35
-9
@@ -24,6 +24,8 @@ commande**.
|
||||
| Auto-update | ❌ | ✅ (vérifie les releases Gitea) |
|
||||
| Mode hors-ligne | Limité | Complet (backend local) |
|
||||
| Gestion vaults & dossiers | Fichiers de config serveur | ✅ UI dédiée + menu contextuel |
|
||||
| Connexion compte central | ✅ (SSO navigateur) | ✅ Liaison d'appareil → admin local |
|
||||
| Environnement central prod/dev | `.env` serveur | ✅ Configuration + premier lancement |
|
||||
|
||||
### Gestion des vaults et dossiers (#159)
|
||||
|
||||
@@ -89,10 +91,33 @@ chmod +x ObsiGate_2.0.0_amd64.AppImage
|
||||
2. Le backend Python démarre automatiquement sur `127.0.0.1:17890`
|
||||
(splash « Démarrage… » pendant le boot).
|
||||
3. La fenêtre s'ouvre et charge l'interface ObsiGate.
|
||||
4. **Premier lancement** : sélectionnez le dossier de vos vaults Obsidian via le
|
||||
sélecteur natif.
|
||||
4. **Premier lancement** : choisissez l'environnement central (prod/dev) et
|
||||
sélectionnez le dossier de vos vaults Obsidian via le sélecteur natif.
|
||||
5. Pour fermer : icône tray → **Quitter** (arrêt propre du backend).
|
||||
|
||||
### 3.1 Connexion (#230)
|
||||
|
||||
Deux chemins, au choix :
|
||||
|
||||
- **Admin local** : `admin` / `chab30` à la création initiale (backend en
|
||||
loopback uniquement). Changez le mot de passe après la première connexion.
|
||||
- **Compte central** : bouton **« Se connecter avec mon compte central »**.
|
||||
L'app démarre une liaison d'appareil sur le site central de l'environnement
|
||||
choisi, ouvre la page d'approbation dans le navigateur ; après approbation,
|
||||
la session de l'admin local est ouverte. Aucun mot de passe central n'est
|
||||
saisi dans la fenêtre.
|
||||
|
||||
L'environnement central se règle au premier lancement ou dans
|
||||
**Configuration → Vaults & dossiers (Desktop)** :
|
||||
|
||||
| Choix | Site central | Barre inter-apps |
|
||||
|---|---|---|
|
||||
| Production | `https://og.dracodev.net` | noms officiels |
|
||||
| Développement | `https://og-dev.dracodev.net` | noms `-dev` dérivés |
|
||||
|
||||
Le backend desktop redémarre après le changement. L'application web Docker
|
||||
n'est pas concernée (les routes desktop et l'UI sont inertes hors Tauri).
|
||||
|
||||
---
|
||||
|
||||
## 4. Construire depuis les sources
|
||||
@@ -128,13 +153,13 @@ build-windows.bat
|
||||
|
||||
Étapes du script :
|
||||
|
||||
1. Tue les processus Python résiduels (`taskkill /F /IM python.exe`).
|
||||
2. Télécharge **Python 3.11 embed** (python.org) → `desktop\python-embed\` +
|
||||
active pip (`python311._pth`).
|
||||
3. `pip install -r ..\backend\requirements.txt` dans l'embed.
|
||||
1. S'exécute depuis `desktop\` (même si appelé via `desktop\build-windows.bat`) et n'arrête que le python embarqué (`*\python-embed\python.exe`).
|
||||
2. Télécharge **Python 3.11 embed** (python.org) → `desktop\python-embed\` et écrit un `python311._pth` complet (`python311.zip`, `.`, `import site`, `..` pour `import backend`).
|
||||
3. `pip install -r ..\backend\requirements.txt` dans l'embed, puis contrôle `import encodings, uvicorn, fastapi, pyotp`.
|
||||
4. **Staging** : copie `..\backend` et `..\frontend` dans `desktop\`.
|
||||
5. `cargo tauri build --target x86_64-pc-windows-msvc --bundles nsis`.
|
||||
6. Copie `python-embed` à côté de l'exécutable pour le mode dev local.
|
||||
5. `cargo tauri build --ci --target x86_64-pc-windows-msvc --bundles nsis,msi`
|
||||
(`.sig` uniquement si `TAURI_SIGNING_PRIVATE_KEY_PASSWORD` est défini — aucune invite interactive).
|
||||
6. Copie le runtime (`python-embed`, `backend`, `frontend`) à côté de l'exécutable pour le mode dev local.
|
||||
7. Nettoie les dossiers stagés.
|
||||
|
||||
→ **Artefact :** `desktop\target\x86_64-pc-windows-msvc\release\bundle\nsis\ObsiGate_2.0.0_x64-setup.exe`
|
||||
@@ -152,7 +177,8 @@ chmod +x build-linux.sh
|
||||
1. Vérifie Rust + Tauri CLI, installe les dépendances système (apt).
|
||||
2. Crée un venv `desktop/python-embed/venv` + `pip install -r ../backend/requirements.txt`.
|
||||
3. **Staging** : copie `../backend` et `../frontend` dans `desktop/`.
|
||||
4. `cargo tauri build --target x86_64-unknown-linux-gnu --bundles deb,appimage`.
|
||||
4. `cargo tauri build --ci --target x86_64-unknown-linux-gnu --bundles deb,appimage`
|
||||
(`.sig` uniquement si `TAURI_SIGNING_PRIVATE_KEY_PASSWORD` est défini — aucune invite interactive).
|
||||
5. Copie le runtime (`python-embed/`, `backend/`, `frontend/`) à côté de l'exécutable.
|
||||
|
||||
→ **Artefacts :**
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
- **Projet** : ObsiGate — Porte d'entrée web pour vaults Obsidian
|
||||
- **Stack** : Python 3.11+ (backend FastAPI) · JavaScript/Vanilla (frontend) · Tauri/Rust (desktop)
|
||||
- **Dernière mise à jour** : 2026-09-29
|
||||
- **Dernière mise à jour** : 2026-11-19
|
||||
|
||||
---
|
||||
|
||||
@@ -368,6 +368,8 @@ Avant de corriger quoi que ce soit, un agent IA doit :
|
||||
| 2026-11-06 | BUG-122 (fusion #141) | Correction | `backend/routers/sso.py`, `backend/auth/router.py`, `tests/test_draco_session.py`, `CHANGELOG.md`, `docs/ISSUES_TODOLIST.md`, `docs/features/deconnexion-globale-bug-122.md`, `VERSION` (+ dérivés) | **BUG-122 — la déconnexion du menu compte ne terminait rien hors ObsiGate** : ajout de `GET /sso/logout`, point d'entrée navigable de la déconnexion globale (logique partagée avec `POST /api/auth/logout`). Vérifié : `test_draco_session.py` 34 passed, ruff 0 et mypy 0 sur les fichiers touchés | 🟢 corrigé (en attente vérif utilisateur) |
|
||||
| 2026-11-08 | BUG-123 + BUG-124 (chantier entrée SSO) | Correction | `frontend/js/auth.js`, `frontend/index.html`, `frontend/draco-barre.js`, `tests/test_draco_barre.py`, `CHANGELOG.md`, `docs/ISSUES_TODOLIST.md`, `docs/ROADMAP.md`, `docs/features/entree-sso-bug-123-124.md`, `VERSION` (+ dérivés) | **BUG-123 — aller-retour SSO refermé à la restauration de session** : `initAuth()` honore le `return_to` sur ses deux chemins de restauration (jeton valide, refresh silencieux au démarrage), comme le faisait déjà `saveToken` après un login frais. **BUG-124 — nom du compte dans la barre dès le login** : barre commune re-vendangée en v0.7.0 (`DRACO_BAR.setUser`, PR dracodev-commons #15), branchée dans `renderUserSection()` et le fetch d'amorçage. Chaînes prouvées en navigateur réel (pile locale aux noms publics, scénario de Bruno) | 🟢 corrigé (en attente vérif utilisateur) |
|
||||
| 2026-11-08 | BUG-125 (suite entrée SSO) | Correction | `frontend/js/auth.js`, `tests/test_draco_barre.py`, `CHANGELOG.md`, `docs/ISSUES_TODOLIST.md`, `docs/ROADMAP.md`, `docs/features/retour-sso-cookie-draco-bug-125.md`, `VERSION` (+ dérivés) | **BUG-125 — retour SSO honoré mais pont sans cookie draco** : quand les cookies `access_token` et `draco_session` ont disparu alors que `sessionStorage` croit la session valide, le chemin court d'`initAuth()` repartait sans échange serveur — aucune réémission du cookie draco — et le pont de l'application sœur, sans jeton, déposait l'utilisateur devant son formulaire nu. Correctif : avec `return_to`, `initAuth()` force le refresh silencieux + `/api/auth/me` (réémission par `DracoRenewalMiddleware`) avant d'honorer le retour. Reproduit puis vérifié en navigateur réel dans la pile « conteneur dev réel » (requête du pont journalisée : sans cookie avant, avec cookie après) | 🟢 corrigé (en attente vérif utilisateur) |
|
||||
| 2026-11-19 | BUG-126 | Correction build desktop Windows | `desktop/build-windows.bat`, `desktop/build-linux.sh`, `tests/test_desktop_build_scripts.py`, `README.md`, `README.fr.md`, `desktop/README.md`, `docs/DEVELOPMENT_AND_RELEASES.md`, `docs/GUIDES/DESKTOP.md`, `CHANGELOG.md`, `docs/ISSUES_TODOLIST.md` | **BUG-126 — l'exe Windows s'ouvrait comme « sans CSS » et le build demandait deux fois un mot de passe.** Cause racine : `desktop\python-embed\python311._pth` ne contenait plus que `import site` + `..` (ni `python311.zip` ni `.`) → `ModuleNotFoundError: No module named 'encodings'`, backend mort avant le health check, fenêtre bloquée sur le HTML embarqué Tauri dont `/static/*` ne résout pas (d'où l'apparence non stylée). Reproduction : `python-embed\python.exe -c "import encodings"` échoue ; après réécriture explicite du `_pth`, le backend servi par le runtime release répond `/api/health` 200 et `/static/style.css` 200 (`text/css`, 363 860 octets). Correctif : `_pth` écrit explicitement (`python311.zip`, `.`, `import site`, `..`), contrôles d'échec sur download/extraction/get-pip/pip + sanity `import encodings, uvicorn, fastapi, pyotp`, copie du runtime complet (`python-embed`, `backend`, `frontend`) à côté de l'exe, exécution depuis `%~dp0`, arrêt limité au python embarqué. Invite de mot de passe : la clé updater n'est utilisée que si `TAURI_SIGNING_PRIVATE_KEY_PASSWORD` est défini, sinon `createUpdaterArtifacts:false` + `--ci` (aucune invite, build sans `.sig`). | 🟢 corrigé (en attente vérif utilisateur) |
|
||||
| 2026-11-19 | #230 + BUG-127 | Fonctionnalité desktop + correction | `desktop/src/main.rs`, `desktop/permissions/commands.toml`, `backend/routers/desktop_sso.py`, `backend/main.py`, `frontend/js/{auth,desktop,config}.js`, `frontend/index.html`, `frontend/style.css`, `frontend/locales/{fr,en}.json`, `tests/test_desktop_sso.py`, `tests/test_desktop_sso_ui.py`, `tests/frontend/desktop.test.mjs`, `tests/test_draco_barre.py`, `docs/features/desktop-sso-environnement-230.md`, `docs/ROADMAP.md`, `CHANGELOG.md`, `docs/ISSUES_TODOLIST.md` | **#230 — l'app desktop peut se connecter avec le compte central et choisir prod/dev.** Constat : le backend desktop sert `127.0.0.1`, le cookie `draco_session` (`Domain=.dracodev.net`) ne lui parvient jamais ; le premier lancement générait un mot de passe admin aléatoire visible seulement dans les logs. Livré : liaison d'appareil sur le central choisi (`/api/v1/liaison`), validation du jeton draco via `/api/auth/me` du central, ouverture de la session de l'admin local par défaut ; login local conservé (admin/chab30 à la création). Sélecteur d'environnement en Configuration + premier lancement, injecté au backend embarqué (`OBSIGATE_DESKTOP*`, `DRACO_AGENT_URL`, `DRACO_OBSIGATE_URL` ; sœurs/Hub `-dev` dérivés). Routes `/api/desktop/sso/*` = 404 hors desktop, UI conditionnée par `isTauriEnv()` : application web Docker inchangée. **BUG-127** : `/liaison` même hôte honoré après login (`return_to`), sinon l'approbation desktop restait bloquée. Vérifié : `test_desktop_sso.py` 9 passed, 32 tests Rust (ACL incluse), `desktop.test.mjs` 30, `test_draco_barre`/`test_desktop_sso_ui`/i18n parity verts. | 🟢 corrigé/livré (en attente vérif utilisateur) |
|
||||
|
||||
---
|
||||
|
||||
|
||||
+14
-1
@@ -1,6 +1,6 @@
|
||||
# ObsiGate — Roadmap
|
||||
|
||||
> **Version :** 2.87.3 | **Dernière mise à jour :** 2026-11-17
|
||||
> **Version :** 2.88.0 | **Dernière mise à jour :** 2026-11-20
|
||||
> **Ce fichier ne contient que le travail à venir** (🔵 En cours + ⚪ Backlog) et un index compact
|
||||
> vers les fonctionnalités livrées.
|
||||
> - **Méthode de livraison à appliquer pour toute tâche : [DELIVERY_WORKFLOW.md](./DELIVERY_WORKFLOW.md)**
|
||||
@@ -30,6 +30,18 @@
|
||||
|
||||
## 🔵 En cours
|
||||
|
||||
### 230. Desktop — connexion avec un compte central + choix prod/dev
|
||||
|
||||
- **Effort :** ~1 jour | **Impact :** 🟡 | **Ouvert :** 2026-11-19 | **Statut :** 🟢 livré (en attente vérif utilisateur)
|
||||
- **Fiche :** [features/desktop-sso-environnement-230.md](./features/desktop-sso-environnement-230.md)
|
||||
- **Description :** l'app desktop embarque un backend sur `127.0.0.1` : le cookie `draco_session` du central (`.dracodev.net`) ne lui parvient pas. Nouveau pont **desktop-only** : liaison d'appareil sur le central choisi (og / og-dev) → jeton draco validé via `/api/auth/me` du central → ouverture de la session de l'admin local par défaut. Le login local (admin/chab30 à la création) reste disponible. Sélecteur d'environnement dans la Configuration et le premier lancement, injecté au backend en `DRACO_AGENT_URL` / `DRACO_OBSIGATE_URL` (les sœurs et le Hub en `-dev` sont dérivés). Aucun impact web Docker : routes `404` hors desktop, UI conditionnée par `isTauriEnv()`.
|
||||
- **Sous-tâches :**
|
||||
- [x] Shell Rust : `environment`, commandes `get_desktop_settings` / `set_desktop_environment`, injection `OBSIGATE_DESKTOP*` + `DRACO_*`, admin local par défaut
|
||||
- [x] Backend `backend/routers/desktop_sso.py` (start/poll/status, validation central, admin local)
|
||||
- [x] Frontend : bouton de connexion central, wizard et Configuration (i18n FR/EN), ouverture navigateur système
|
||||
- [x] Retour `/liaison` même hôte après login central (BUG-127)
|
||||
- [x] Tests backend, Rust, frontend + fiche + CHANGELOG
|
||||
|
||||
### 229. Liaison d'appareil — flux « code d'appareil » émettant un jeton draco (#75)
|
||||
|
||||
- **Effort :** ~0,5 jour | **Impact :** 🟡 | **Ouvert :** 2026-11-16 | **Statut :** ✅ livré en 2.87.0 (PR #76 en attente de fusion — voir CHANGELOG ; redéploiement Docker requis)
|
||||
@@ -1264,6 +1276,7 @@
|
||||
| BUG-123 | Aller-retour SSO — le `return_to` de `/sso/authorize` est honoré aussi après restauration de session au démarrage (`initAuth`), pas seulement après un login frais | Unreleased | [features/entree-sso-bug-123-124.md](./features/entree-sso-bug-123-124.md) |
|
||||
| BUG-124 | Barre commune v0.7.0 — `DRACO_BAR.setUser` branché dans `renderUserSection()` : le nom du compte s'affiche dans le menu compte dès le login, sans rechargement | Unreleased | [features/entree-sso-bug-123-124.md](./features/entree-sso-bug-123-124.md) |
|
||||
| BUG-125 | Aller-retour SSO — à l'arrivée d'un `/sso/authorize`, `initAuth` force le refresh silencieux + `/api/auth/me` pour que le cookie `draco_session` soit réémis avant que le retour soit honoré (pont sœur sans jeton = formulaire nu) | Unreleased | [features/retour-sso-cookie-draco-bug-125.md](./features/retour-sso-cookie-draco-bug-125.md) |
|
||||
| 230 | Desktop — connexion avec un compte central (liaison d'appareil → admin local) + sélecteur prod/dev, admin local par défaut, sans impact web Docker | Unreleased | [features/desktop-sso-environnement-230.md](./features/desktop-sso-environnement-230.md) |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
# #230 — Desktop : connexion avec un compte central + choix d'environnement
|
||||
|
||||
> **Statut :** livré (en attente de vérification utilisateur)
|
||||
> **Impact :** desktop uniquement — l'application web Docker est inchangée.
|
||||
> **Fiche liée :** [BUG-127](../ISSUES_TODOLIST.md) (retour `/liaison` même hôte).
|
||||
|
||||
## Problème
|
||||
|
||||
L'application desktop embarque son propre backend FastAPI sur
|
||||
`http://127.0.0.1:<port>`. Le cookie `draco_session` émis par le site
|
||||
central ( `Domain=.dracodev.net` ) n'est **jamais** envoyé à cette origine :
|
||||
|
||||
- la connexion locale (`admin` + mot de passe) restait possible, mais aucun
|
||||
moyen de se connecter avec le compte central ;
|
||||
- les liens inter-apps de la barre pointaient toujours la production, sans
|
||||
choix dev/prod ;
|
||||
- au premier lancement, le mot de passe admin était aléatoire et affiché
|
||||
uniquement dans les logs — inaccessible sans terminal.
|
||||
|
||||
## Décisions (validation Bruno, 2026-11-19)
|
||||
|
||||
| Sujet | Décision |
|
||||
|---|---|
|
||||
| Méthode de login central | **Liaison d'appareil** existante (`/api/v1/liaison`) : pas de mot de passe central saisi dans l'app, aucune modification du backend web. |
|
||||
| Accès local après validation | **Déverrouille l'admin local par défaut** (app mono-utilisateur). Aucun utilisateur local créé. |
|
||||
| Choix d'environnement | **Configuration + premier lancement**, persisté dans `%APPDATA%\ObsiGate\config.json`. |
|
||||
| Admin local par défaut | `admin` / `chab30` à la création initiale (backend en loopback), modifiable ensuite. |
|
||||
|
||||
## Flux
|
||||
|
||||
1. Écran de connexion desktop : bouton **« Se connecter avec mon compte
|
||||
central »** + libellé de l'environnement (og / og-dev).
|
||||
2. `POST /api/desktop/sso/start` (backend local) → `POST {central}/api/v1/liaison`
|
||||
(serveur-à-serveur) → code `XXXX-XXXX`, URL d'approbation.
|
||||
3. L'app ouvre l'URL dans le navigateur système (`shell:allow-open`).
|
||||
L'utilisateur se connecte au central si besoin, puis approuve.
|
||||
4. `POST /api/desktop/sso/poll` (toutes les 2 s) → `POST {central}/api/v1/liaison/sonder`.
|
||||
À l'approbation, le backend local :
|
||||
- valide le jeton draco via `GET {central}/api/auth/me` (cookie
|
||||
`draco_session`, **jamais journalisé**) ;
|
||||
- sélectionne l'admin local (`OBSIGATE_ADMIN_USER`, puis `admin`, puis le
|
||||
premier admin actif) ;
|
||||
- émet les jetons natifs locaux avec le même format que `/api/auth/login`.
|
||||
5. L'interface applique `AuthManager.saveToken()` puis le démarrage habituel
|
||||
(`_onLoginSuccess`). Le login local reste disponible en parallèle.
|
||||
|
||||
## Environnement
|
||||
|
||||
Le shell Rust injecte dans le backend embarqué **uniquement** :
|
||||
|
||||
| Variable | Valeur prod | Valeur dev |
|
||||
|---|---|---|
|
||||
| `OBSIGATE_DESKTOP_SSO` | `1` | `1` |
|
||||
| `OBSIGATE_DESKTOP_ENV` | `prod` | `dev` |
|
||||
| `DRACO_AGENT_URL` | `https://agent.dracodev.net` | `https://agent-dev.dracodev.net` |
|
||||
| `DRACO_OBSIGATE_URL` | `https://og.dracodev.net` | `https://og-dev.dracodev.net` |
|
||||
| `OBSIGATE_ADMIN_USER` / `_PASSWORD` | `admin` / `chab30` | idem |
|
||||
|
||||
`backend/draco_config` dérive les sœurs (Flowdeck, TikTak, Kanbante, ShaarIt,
|
||||
Hub) en `-dev` depuis l'hôte de l'agent (BUG-120), donc `window.DRACO_URLS`
|
||||
suit l'environnement choisi. Gitea reste en prod.
|
||||
|
||||
Le changement d'environnement (Configuration ou wizard) enregistre la valeur
|
||||
puis appelle `restart_backend` ; les variables sont réinjectées au prochain
|
||||
démarrage du backend local.
|
||||
|
||||
## Inertie hors desktop
|
||||
|
||||
- Les routes `/api/desktop/sso/*` répondent **404** tant que
|
||||
`OBSIGATE_DESKTOP_SSO` n'est pas activé (le shell Tauri seul le pose).
|
||||
- Côté frontend, tout est conditionné par `isTauriEnv()` : la page web Docker
|
||||
ne montre ni le bouton central, ni le sélecteur d'environnement.
|
||||
- Aucun changement de comportement pour les connexions locales existantes.
|
||||
|
||||
## Sécurité
|
||||
|
||||
- `start` / `poll` ne transportent aucun secret d'utilisateur ; le jeton
|
||||
central n'est utilisé que dans l'appel serveur-à-serveur `/api/auth/me`.
|
||||
- Seuls les hôtes `og.dracodev.net` et `og-dev.dracodev.net` sont acceptés
|
||||
(pas de SSRF arbitraire). L'URL d'approbation est reconstruite sur ce site
|
||||
central en **https** : derrière un reverse proxy qui ne transmet pas
|
||||
`X-Forwarded-Proto`, le central renvoie parfois `http://` via
|
||||
`request.base_url` (observé en prod le 2026-11-19).
|
||||
- Le jeton n'est ni persisté ni loggé. La session locale est un jeton natif
|
||||
normal (cookie refresh 7/30 jours) : une révocation centrale ne coupe pas
|
||||
rétroactivement cette session locale (utiliser « Déconnexion » dans l'app
|
||||
pour la terminer).
|
||||
- Le backend desktop n'écoute que sur `127.0.0.1` ; les POST `start`/`poll`
|
||||
refusent en plus une origine navigateur non locale (`Origin`).
|
||||
- BUG-127 : `/liaison` (même hôte) est honoré après le login central, sinon
|
||||
l'approbation ne reprenait pas ; les autres retours même-hôte restent
|
||||
ignorés (pas de boucle).
|
||||
|
||||
## Tests
|
||||
|
||||
- `tests/test_desktop_sso.py` (9) : routes inertes hors desktop, statut,
|
||||
délégation à la liaison, attente/approbation/refus, validation central,
|
||||
sélection de l'admin local, refus d'un hôte central inconnu.
|
||||
- `desktop/src/main.rs` : normalisation d'environnement, URLs, variables
|
||||
injectées, compatibilité des anciennes configs (32 tests Rust, dont l'ACL).
|
||||
- `tests/frontend/desktop.test.mjs` (30) : commandes d'environnement, label,
|
||||
dégradation web.
|
||||
- `tests/test_desktop_sso_ui.py` + `tests/test_draco_barre.py` : garde-fous
|
||||
UI/Tauri-only et retour `/liaison` même hôte.
|
||||
@@ -121,5 +121,21 @@
|
||||
`webauthn-key-item`), boutons `.config-btn-sm` (primaire/secondaire),
|
||||
override mobile 44px dans le bloc `#config-modal`.
|
||||
- [x] Tests : `test_default_first_run_config`, `test_welcome_doc_embedded`
|
||||
— `cargo test` 28 passed ; suites frontend vertes (validate-imports,
|
||||
- `cargo test` 28 passed ; suites frontend vertes (validate-imports,
|
||||
unit, config-mobile, desktop-roots, settings-order) + E2E locale.
|
||||
|
||||
## I. Connexion centralisée & environnement prod/dev - #230 - 🟢 livré (2026-11-19)
|
||||
|
||||
- [x] Liaison d'appareil sur le central choisi → validation du jeton draco
|
||||
par `/api/auth/me` → session de l'admin local par défaut
|
||||
(`backend/routers/desktop_sso.py`).
|
||||
- [x] Shell Rust : champ `environment`, commandes `get_desktop_settings` /
|
||||
`set_desktop_environment`, injection `OBSIGATE_DESKTOP*` + `DRACO_*` au
|
||||
seul backend embarqué, admin local `admin` / `chab30` à la création.
|
||||
- [x] UI : bouton « compte central » sur l'écran de connexion, sélecteur
|
||||
prod/dev dans la Configuration et le wizard (i18n FR/EN), ouverture du
|
||||
navigateur système via `open_external_url` (ACL).
|
||||
- [x] Aucun impact web Docker : routes `/api/desktop/sso/*` en 404 hors
|
||||
desktop, UI conditionnée par `isTauriEnv()`.
|
||||
- [x] BUG-127 : retour `/liaison` même hôte honoré après le login central.
|
||||
- **Fiche dédiée :** [`desktop-sso-environnement-230.md`](./desktop-sso-environnement-230.md).
|
||||
|
||||
@@ -2170,6 +2170,31 @@
|
||||
racine chargés par l'application desktop.
|
||||
</p>
|
||||
|
||||
<!-- #230 — environnement central (prod/dev) -->
|
||||
<div class="desktop-env-row">
|
||||
<label
|
||||
for="cfg-desktop-environment"
|
||||
data-i18n="config.desktop_environment"
|
||||
>Environnement central</label>
|
||||
<select id="cfg-desktop-environment">
|
||||
<option value="prod" data-i18n="config.desktop_env_prod">Production (og.dracodev.net)</option>
|
||||
<option value="dev" data-i18n="config.desktop_env_dev">Développement (og-dev.dracodev.net)</option>
|
||||
</select>
|
||||
<span
|
||||
class="desktop-env-status"
|
||||
id="cfg-desktop-environment-status"
|
||||
></span>
|
||||
</div>
|
||||
<p
|
||||
class="config-description"
|
||||
data-i18n="config.desktop_environment_desc"
|
||||
>
|
||||
Site central utilisé pour la connexion
|
||||
centralisée et les liens inter-apps. Le
|
||||
backend desktop redémarre après le
|
||||
changement.
|
||||
</p>
|
||||
|
||||
<div
|
||||
id="desktop-roots-list"
|
||||
class="desktop-roots-list"
|
||||
@@ -4968,6 +4993,7 @@
|
||||
<li data-i18n="guide105.des_get">L'application desktop ObsiGate (Tauri) embarque le serveur Python : aucune installation de Docker nécessaire. Elle se télécharge sur la page des Releases du dépôt et se met à jour automatiquement (updater signé).</li>
|
||||
<li data-i18n="guide105.des_wizard">Au premier lancement, un assistant demande le dossier de vos vaults (ou crée un vault de démonstration). Chaque document peut être détaché en fenêtre native séparée.</li>
|
||||
<li data-i18n="guide105.des_data">Les données desktop restent dans le répertoire applicatif ; les vaults pointent sur vos dossiers existants. Toutes les fonctionnalités web (recherche, IA, partage) sont disponibles.</li>
|
||||
<li data-i18n="guide105.des_central">La connexion accepte le compte admin local ou votre compte central (approbation dans le navigateur). L'environnement central (production og.dracodev.net ou développement og-dev.dracodev.net) se choisit au premier lancement et dans Configuration → Vaults & dossiers (Desktop).</li>
|
||||
<li data-i18n="guide105.des_native">Menu système natif, raccourci global optionnel pour afficher/masquer la fenêtre et jumplist des vaults récents.</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
+224
-1
@@ -4,6 +4,12 @@ import { safeCreateIcons, escapeHtml } from './utils.js';
|
||||
import { showToast, closeHeaderMenu, closeMobileSidebar } from './ui.js';
|
||||
import { t, getLocale, setLocale } from './i18n.js';
|
||||
import { showWelcome } from './viewer.js';
|
||||
import {
|
||||
isTauriEnv,
|
||||
getDesktopSettings,
|
||||
desktopEnvironmentLabel,
|
||||
openExternalUrl,
|
||||
} from './desktop.js';
|
||||
|
||||
// ── Global logout handler for header dropdown onclick ────────────────────
|
||||
// Defined at module top level so it's always available, even if
|
||||
@@ -135,8 +141,14 @@ const AuthManager = {
|
||||
const u = new URL(rt);
|
||||
const okHost = u.hostname === "dracodev.net"
|
||||
|| u.hostname.endsWith(".dracodev.net");
|
||||
const sameHost = u.hostname === window.location.hostname;
|
||||
// #230 : la page publique /liaison (approbation d'appareil) renvoie
|
||||
// vers elle-même après connexion (`return_to` même hôte). On l'honore
|
||||
// pour que la liaison desktop reprenne après le login central ; les
|
||||
// autres retours même-hôte restent ignorés (pas de boucle).
|
||||
const sameHostLiaison = sameHost && u.pathname.startsWith("/liaison");
|
||||
if (u.protocol === "https:" && okHost
|
||||
&& u.hostname !== window.location.hostname) {
|
||||
&& (!sameHost || sameHostLiaison)) {
|
||||
window.location.replace(rt);
|
||||
return true;
|
||||
}
|
||||
@@ -922,6 +934,210 @@ function showRecoveryChallenge(username, rememberMe, loginForm, mfaSection) {
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Desktop — connexion avec un compte central (#230)
|
||||
// ---------------------------------------------------------------------------
|
||||
// Le backend desktop démarre une liaison d'appareil sur le site central
|
||||
// (og / og-dev), l'utilisateur approuve dans son navigateur, puis le backend
|
||||
// valide le jeton draco et ouvre la session de l'admin local. Aucun de ces
|
||||
// appels n'existe sur le web : tout est conditionné par isTauriEnv().
|
||||
|
||||
let _centralPollTimer = null;
|
||||
let _centralCancelled = false;
|
||||
|
||||
async function _jsonOrEmpty(res) {
|
||||
try { return await res.json(); } catch (e) { return {}; }
|
||||
}
|
||||
|
||||
function _centralSetStatus(text, isError) {
|
||||
const el = document.getElementById("login-central-status");
|
||||
if (!el) return;
|
||||
el.textContent = text || "";
|
||||
el.classList.toggle("error", !!isError);
|
||||
}
|
||||
|
||||
function _centralShowError(text) {
|
||||
_centralSetStatus(text, true);
|
||||
const el = document.getElementById("login-error");
|
||||
if (el) {
|
||||
el.textContent = text || "";
|
||||
if (text) el.classList.remove("hidden");
|
||||
else el.classList.add("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
function _centralResetPanel() {
|
||||
if (_centralPollTimer) {
|
||||
clearTimeout(_centralPollTimer);
|
||||
_centralPollTimer = null;
|
||||
}
|
||||
_centralCancelled = true;
|
||||
const panel = document.getElementById("login-central-panel");
|
||||
if (panel) panel.remove();
|
||||
const btn = document.getElementById("login-central-btn");
|
||||
if (btn) btn.disabled = false;
|
||||
}
|
||||
|
||||
async function _centralPollOnce(state) {
|
||||
if (_centralCancelled) return;
|
||||
let res;
|
||||
try {
|
||||
res = await fetch("/api/desktop/sso/poll", {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
demande_id: state.demande_id,
|
||||
code_appareil: state.code_appareil,
|
||||
remember_me: state.rememberMe,
|
||||
}),
|
||||
});
|
||||
} catch (e) {
|
||||
_centralShowError(t("auth.central_error"));
|
||||
_centralResetPanel();
|
||||
return;
|
||||
}
|
||||
const payload = await _jsonOrEmpty(res);
|
||||
if (_centralCancelled) return;
|
||||
if (!res.ok) {
|
||||
_centralShowError(payload.detail || t("auth.central_error"));
|
||||
_centralResetPanel();
|
||||
return;
|
||||
}
|
||||
if (payload.statut === "approuvee") {
|
||||
AuthManager.saveToken(payload);
|
||||
_centralResetPanel();
|
||||
const central = payload.central_user || {};
|
||||
const name = central.display_name || central.username;
|
||||
showToast(name ? t("auth.central_success", { name: name })
|
||||
: t("auth.central_success", { name: "" }), "success");
|
||||
await _onLoginSuccess();
|
||||
safeCreateIcons();
|
||||
return;
|
||||
}
|
||||
if (payload.statut === "en_attente") {
|
||||
if (Date.now() > state.deadline) {
|
||||
_centralShowError(t("auth.central_expired"));
|
||||
_centralResetPanel();
|
||||
return;
|
||||
}
|
||||
_centralSetStatus(t("auth.central_waiting"), false);
|
||||
_centralPollTimer = setTimeout(() => _centralPollOnce(state), 2000);
|
||||
return;
|
||||
}
|
||||
if (payload.statut === "refusee") {
|
||||
_centralShowError(t("auth.central_refused"));
|
||||
} else if (payload.statut === "expiree" || payload.statut === "livree") {
|
||||
_centralShowError(t("auth.central_expired"));
|
||||
} else {
|
||||
_centralShowError(t("auth.central_error"));
|
||||
}
|
||||
_centralResetPanel();
|
||||
}
|
||||
|
||||
async function startCentralLogin() {
|
||||
if (_centralPollTimer) return;
|
||||
const btn = document.getElementById("login-central-btn");
|
||||
if (btn) btn.disabled = true;
|
||||
const loginError = document.getElementById("login-error");
|
||||
if (loginError) loginError.classList.add("hidden");
|
||||
_centralSetStatus(t("auth.central_starting"), false);
|
||||
|
||||
let start;
|
||||
try {
|
||||
const res = await fetch("/api/desktop/sso/start", {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
});
|
||||
const payload = await _jsonOrEmpty(res);
|
||||
if (!res.ok) {
|
||||
_centralShowError(payload.detail || t("auth.central_error"));
|
||||
if (btn) btn.disabled = false;
|
||||
return;
|
||||
}
|
||||
start = payload;
|
||||
} catch (e) {
|
||||
_centralShowError(t("auth.central_error"));
|
||||
if (btn) btn.disabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const card = document.querySelector(".login-card");
|
||||
if (!card) return;
|
||||
const old = document.getElementById("login-central-panel");
|
||||
if (old) old.remove();
|
||||
const panel = document.createElement("div");
|
||||
panel.id = "login-central-panel";
|
||||
panel.className = "login-central-panel";
|
||||
panel.innerHTML =
|
||||
'<div>' + escapeHtml(t("auth.central_code")) + '</div>' +
|
||||
'<div class="login-central-code">' + escapeHtml(start.code_utilisateur || "") + '</div>' +
|
||||
'<p class="login-central-status" id="login-central-status"></p>' +
|
||||
'<div class="login-central-actions">' +
|
||||
'<button type="button" id="login-central-open">' + escapeHtml(t("auth.central_open")) + '</button>' +
|
||||
'<button type="button" id="login-central-cancel">' + escapeHtml(t("auth.central_cancel")) + '</button>' +
|
||||
'</div>';
|
||||
card.appendChild(panel);
|
||||
|
||||
const openBtn = document.getElementById("login-central-open");
|
||||
if (openBtn) {
|
||||
openBtn.addEventListener("click", () => openExternalUrl(start.url_liaison_absolue));
|
||||
}
|
||||
const cancelBtn = document.getElementById("login-central-cancel");
|
||||
if (cancelBtn) {
|
||||
cancelBtn.addEventListener("click", () => {
|
||||
_centralSetStatus("");
|
||||
_centralResetPanel();
|
||||
if (btn) btn.disabled = false;
|
||||
});
|
||||
}
|
||||
|
||||
_centralCancelled = false;
|
||||
_centralSetStatus(t("auth.central_waiting"), false);
|
||||
await openExternalUrl(start.url_liaison_absolue);
|
||||
const rememberMe = document.getElementById("remember-me");
|
||||
const state = {
|
||||
demande_id: start.demande_id,
|
||||
code_appareil: start.code_appareil,
|
||||
rememberMe: rememberMe ? rememberMe.checked : true,
|
||||
deadline: Date.now() + Math.max(30, Number(start.expire_dans_s) || 600) * 1000,
|
||||
};
|
||||
_centralPollTimer = setTimeout(() => _centralPollOnce(state), 1500);
|
||||
}
|
||||
|
||||
async function initDesktopCentralLogin() {
|
||||
if (!isTauriEnv()) return;
|
||||
const card = document.querySelector(".login-card");
|
||||
const form = document.getElementById("login-form");
|
||||
if (!card || !form || document.getElementById("login-central")) return;
|
||||
|
||||
const box = document.createElement("div");
|
||||
box.id = "login-central";
|
||||
box.className = "login-central";
|
||||
box.innerHTML =
|
||||
'<button type="button" class="login-central-btn" id="login-central-btn">' +
|
||||
escapeHtml(t("auth.central_login")) + '</button>' +
|
||||
'<p class="login-central-hint" id="login-central-hint"></p>';
|
||||
form.insertAdjacentElement("afterend", box);
|
||||
|
||||
let settings;
|
||||
try { settings = await getDesktopSettings(); } catch (e) { settings = undefined; }
|
||||
const hint = document.getElementById("login-central-hint");
|
||||
if (hint) {
|
||||
if (settings && settings.central_url) {
|
||||
hint.textContent = desktopEnvironmentLabel(
|
||||
settings.environment, settings.central_url);
|
||||
} else {
|
||||
hint.textContent = t("auth.central_unavailable");
|
||||
}
|
||||
}
|
||||
const btn = document.getElementById("login-central-btn");
|
||||
if (btn) {
|
||||
if (!settings || !settings.central_url) btn.disabled = true;
|
||||
btn.addEventListener("click", startCentralLogin);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Login form handler
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -930,8 +1146,15 @@ function initLoginForm() {
|
||||
const form = document.getElementById("login-form");
|
||||
if (!form) return;
|
||||
|
||||
// Desktop uniquement : bouton « compte central » (#230).
|
||||
initDesktopCentralLogin();
|
||||
|
||||
form.addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
// Un login local annule toute tentative de connexion centralisée en cours.
|
||||
if (_centralPollTimer || document.getElementById("login-central-panel")) {
|
||||
_centralResetPanel();
|
||||
}
|
||||
const username = document.getElementById("login-username").value;
|
||||
const password = document.getElementById("login-password").value;
|
||||
const rememberMe = document.getElementById("remember-me").checked;
|
||||
|
||||
+24
-1
@@ -7,7 +7,7 @@ import { escapeHtml, safeCreateIcons } from './utils.js';
|
||||
import { showToast, closeHeaderMenu, closeMobileSidebar } from './ui.js';
|
||||
import { t, setLocale, getLocale } from './i18n.js';
|
||||
import { getModelCapabilities, renderCapabilityBadges, refreshAIPickers } from './ai.js';
|
||||
import { isTauriEnv, invoke, pickAndAddVault, pickAndAddDir, removeRoot } from './desktop.js';
|
||||
import { isTauriEnv, invoke, pickAndAddVault, pickAndAddDir, removeRoot, getDesktopSettings, setDesktopEnvironment } from './desktop.js';
|
||||
import { openSidebarChat, filterChatMessages as _filterChat } from './filechat.js';
|
||||
|
||||
let _recentTimestampTimer = null;
|
||||
@@ -800,6 +800,29 @@ async function renderDesktopRoots() {
|
||||
}
|
||||
section.style.display = "";
|
||||
if (navLink && navLink.parentElement) navLink.parentElement.style.display = "";
|
||||
|
||||
// #230 — environnement central prod/dev.
|
||||
const settings = await getDesktopSettings();
|
||||
const envSelect = document.getElementById("cfg-desktop-environment");
|
||||
const envStatus = document.getElementById("cfg-desktop-environment-status");
|
||||
if (envSelect && settings) {
|
||||
envSelect.value = settings.environment === "dev" ? "dev" : "prod";
|
||||
envSelect.disabled = false;
|
||||
if (envStatus) envStatus.textContent = "";
|
||||
envSelect.onchange = async () => {
|
||||
envSelect.disabled = true;
|
||||
if (envStatus) envStatus.textContent = t("desktop.env_restarting");
|
||||
const saved = await setDesktopEnvironment(envSelect.value);
|
||||
if (saved) {
|
||||
showToast(t("config.desktop_env_saved"), "success");
|
||||
await invoke("restart_backend");
|
||||
} else {
|
||||
envSelect.disabled = false;
|
||||
if (envStatus) envStatus.textContent = "";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const vaults = (await invoke("list_vaults")) || [];
|
||||
const dirs = (await invoke("list_dirs")) || [];
|
||||
const list = document.getElementById("desktop-roots-list");
|
||||
|
||||
+93
-4
@@ -12,6 +12,8 @@
|
||||
* Usage: import { initDesktopIntegration } from './desktop.js';
|
||||
*/
|
||||
|
||||
import { t } from './i18n.js';
|
||||
|
||||
// ── Detection ──────────────────────────────────────────────────────────────
|
||||
// window.__TAURI__ is injected by Tauri when app.withGlobalTauri === true.
|
||||
// window.__TAURI_INTERNALS__ is a secondary signal used by some Tauri builds.
|
||||
@@ -52,6 +54,54 @@ export async function getSystemTheme() {
|
||||
return 'light';
|
||||
}
|
||||
|
||||
// ── Environnement central (#230) ───────────────────────────────────────────
|
||||
// prod = https://og.dracodev.net, dev = https://og-dev.dracodev.net.
|
||||
// Persisté par le shell Rust (%APPDATA%/ObsiGate/config.json) et injecté au
|
||||
// backend embarqué en DRACO_* ; sans effet sur l'application web.
|
||||
|
||||
export function desktopEnvironmentLabel(env, centralUrl) {
|
||||
const key = env === 'dev' ? 'dev' : 'prod';
|
||||
const host = centralUrl || (key === 'dev'
|
||||
? 'https://og-dev.dracodev.net'
|
||||
: 'https://og.dracodev.net');
|
||||
return t('desktop.env_' + key) + ' — ' + host.replace(/^https?:\/\//, '');
|
||||
}
|
||||
|
||||
export async function getDesktopSettings() {
|
||||
if (!isTauriEnv()) return undefined;
|
||||
return await invoke('get_desktop_settings');
|
||||
}
|
||||
|
||||
export async function setDesktopEnvironment(environment) {
|
||||
if (!isTauriEnv()) return undefined;
|
||||
return await invoke('set_desktop_environment', { environment: environment });
|
||||
}
|
||||
|
||||
// Opens a URL in the user's default browser (Tauri shell plugin). Returns
|
||||
// false when unavailable (web), true otherwise.
|
||||
export async function openExternalUrl(url) {
|
||||
if (!isTauriEnv() || !url) return false;
|
||||
// Commande Rust : valide https://*.dracodev.net puis ouvre le navigateur
|
||||
// système (shell:allow-open). `true` = succès, `undefined` = échec IPC.
|
||||
const res = await invoke('open_external_url', { url: url });
|
||||
if (res === true) return true;
|
||||
try {
|
||||
const shell = window.__TAURI__ && window.__TAURI__.shell;
|
||||
if (shell && typeof shell.open === 'function') {
|
||||
await shell.open(url);
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[desktop] shell.open failed:', e);
|
||||
}
|
||||
try {
|
||||
window.open(url, '_blank', 'noopener');
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Theme preference detection ─────────────────────────────────────────────
|
||||
// The real theme engine is themes.js: it persists the *mode* under
|
||||
// 'obsigate-theme-mode' (dark/light/high-contrast/sepia). Absence of that key
|
||||
@@ -235,7 +285,7 @@ export async function initDesktopWizard() {
|
||||
if (!shouldShowWizard({ hasVaultPath: wizardDone })) return;
|
||||
|
||||
// Defer so the app shell is fully rendered before injecting the banner.
|
||||
setTimeout(function () {
|
||||
setTimeout(async function () {
|
||||
if (document.getElementById('obsigate-desktop-wizard')) return;
|
||||
const banner = document.createElement('div');
|
||||
banner.id = 'obsigate-desktop-wizard';
|
||||
@@ -250,10 +300,44 @@ export async function initDesktopWizard() {
|
||||
|
||||
const text = document.createElement('span');
|
||||
text.style.cssText = 'flex:1;min-width:220px;font-size:13px;color:var(--text,#e6edf3);';
|
||||
text.textContent = 'Bienvenue dans ObsiGate Desktop. Choisissez le dossier de vos vaults Obsidian pour commencer.';
|
||||
text.textContent = t('desktop.wizard_text');
|
||||
|
||||
// #230 : choix prod/dev avant la première connexion. Persisté côté Rust ;
|
||||
// le backend redémarre pour recevoir les URL DRACO_* de l'environnement.
|
||||
const settings = await getDesktopSettings();
|
||||
const currentEnv = settings && settings.environment ? settings.environment : 'prod';
|
||||
const envWrap = document.createElement('label');
|
||||
envWrap.style.cssText = 'display:flex;flex-direction:column;gap:4px;font-size:12px;color:var(--text-2,#8b949e);min-width:190px;';
|
||||
const envLabel = document.createElement('span');
|
||||
envLabel.textContent = t('desktop.wizard_env_label');
|
||||
const envSelect = document.createElement('select');
|
||||
envSelect.id = 'desktop-wizard-environment';
|
||||
envSelect.style.cssText = 'padding:6px 8px;border-radius:6px;border:1px solid var(--border,#21262d);background:var(--bg-primary,#0d1117);color:var(--text,#e6edf3);font-size:13px;';
|
||||
[['prod', t('desktop.env_prod')], ['dev', t('desktop.env_dev')]].forEach(function (pair) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = pair[0];
|
||||
opt.textContent = pair[1];
|
||||
envSelect.appendChild(opt);
|
||||
});
|
||||
envSelect.value = currentEnv === 'dev' ? 'dev' : 'prod';
|
||||
const envStatus = document.createElement('span');
|
||||
envSelect.addEventListener('change', async function () {
|
||||
envSelect.disabled = true;
|
||||
envStatus.textContent = t('desktop.env_restarting');
|
||||
const saved = await setDesktopEnvironment(envSelect.value);
|
||||
if (saved) {
|
||||
await invoke('restart_backend');
|
||||
} else {
|
||||
envSelect.disabled = false;
|
||||
envStatus.textContent = '';
|
||||
}
|
||||
});
|
||||
envWrap.appendChild(envLabel);
|
||||
envWrap.appendChild(envSelect);
|
||||
envWrap.appendChild(envStatus);
|
||||
|
||||
const pickBtn = document.createElement('button');
|
||||
pickBtn.textContent = 'Choisir mon dossier';
|
||||
pickBtn.textContent = t('desktop.wizard_pick');
|
||||
pickBtn.style.cssText = 'background:#7c3aed;color:#fff;border:none;border-radius:6px;padding:8px 14px;cursor:pointer;font-weight:600;font-size:13px;';
|
||||
pickBtn.addEventListener('click', async function () {
|
||||
const p = await pickAndAddVault();
|
||||
@@ -261,7 +345,7 @@ export async function initDesktopWizard() {
|
||||
});
|
||||
|
||||
const laterBtn = document.createElement('button');
|
||||
laterBtn.textContent = 'Plus tard';
|
||||
laterBtn.textContent = t('desktop.wizard_later');
|
||||
laterBtn.style.cssText = 'background:transparent;color:var(--text-2,#8b949e);border:1px solid var(--border,#21262d);border-radius:6px;padding:8px 14px;cursor:pointer;font-size:13px;';
|
||||
laterBtn.addEventListener('click', function () {
|
||||
dismissWizard();
|
||||
@@ -269,6 +353,7 @@ export async function initDesktopWizard() {
|
||||
});
|
||||
|
||||
banner.appendChild(text);
|
||||
banner.appendChild(envWrap);
|
||||
banner.appendChild(pickBtn);
|
||||
banner.appendChild(laterBtn);
|
||||
document.body.appendChild(banner);
|
||||
@@ -307,6 +392,10 @@ export default {
|
||||
getSystemTheme,
|
||||
hasExplicitThemeMode,
|
||||
syncSystemTheme,
|
||||
desktopEnvironmentLabel,
|
||||
getDesktopSettings,
|
||||
setDesktopEnvironment,
|
||||
openExternalUrl,
|
||||
defineBackendCrashBanner,
|
||||
pickVaultFolder,
|
||||
pickAndAddVault,
|
||||
|
||||
@@ -218,6 +218,17 @@
|
||||
"auth.session_expired": "Session expired, please sign in again",
|
||||
"auth.user_deleted": "User deleted",
|
||||
"auth.username": "Username",
|
||||
"auth.central_login": "Sign in with my central account",
|
||||
"auth.central_unavailable": "Central sign-in unavailable.",
|
||||
"auth.central_starting": "Preparing central sign-in…",
|
||||
"auth.central_code": "Code to approve on the central site:",
|
||||
"auth.central_open": "Open approval page",
|
||||
"auth.central_cancel": "Cancel",
|
||||
"auth.central_waiting": "Waiting for approval…",
|
||||
"auth.central_success": "Central account verified ({name}).",
|
||||
"auth.central_refused": "The link request was refused.",
|
||||
"auth.central_expired": "The request expired. Try again.",
|
||||
"auth.central_error": "Cannot reach the central site.",
|
||||
"auto.0257e77f": "🧰 Toolbox ▾",
|
||||
"auto.033a9ddf": "Default model",
|
||||
"auto.03a6e5b1": "The operators used are displayed as",
|
||||
@@ -542,6 +553,18 @@
|
||||
"desktop.add_vault": "📁 Add a vault",
|
||||
"desktop.add_dir": "📂 Add a folder",
|
||||
"desktop.roots_empty": "No vault or folder configured.",
|
||||
"desktop.env_prod": "Production (og.dracodev.net)",
|
||||
"desktop.env_dev": "Development (og-dev.dracodev.net)",
|
||||
"desktop.env_restarting": "Restarting the backend…",
|
||||
"desktop.wizard_text": "Welcome to ObsiGate Desktop. Choose your Obsidian vault folder and the central environment to get started.",
|
||||
"desktop.wizard_env_label": "Central environment",
|
||||
"desktop.wizard_pick": "Choose my folder",
|
||||
"desktop.wizard_later": "Later",
|
||||
"config.desktop_environment": "Central environment",
|
||||
"config.desktop_environment_desc": "Central site used for central sign-in and inter-app links. The desktop backend restarts after the change.",
|
||||
"config.desktop_env_prod": "Production (og.dracodev.net)",
|
||||
"config.desktop_env_dev": "Development (og-dev.dracodev.net)",
|
||||
"config.desktop_env_saved": "Environment saved. Restarting the backend…",
|
||||
"config.section_historique-recent-redemarrage-non-requis": "📋 Recent History\n No restart required",
|
||||
"config.section_indicateurs-visuels": "Indicateurs visuels",
|
||||
"config.section_intelligence-artificielle-dans-l-editeur": "🤖 AI in the Editor",
|
||||
@@ -2630,6 +2653,7 @@
|
||||
"guide105.des_get": "The ObsiGate desktop app (Tauri) embeds the Python server: no Docker install needed. Download it from the repository's Releases page; it auto-updates (signed updater).",
|
||||
"guide105.des_wizard": "On first launch a wizard asks for your vaults folder (or creates a demo vault). Any document can be detached into its own native window.",
|
||||
"guide105.des_data": "Desktop data stays in the app directory; vaults point at your existing folders. Every web feature (search, AI, sharing) is available.",
|
||||
"guide105.des_central": "Sign-in accepts the local admin account or your central account (approval in your browser). The central environment (production og.dracodev.net or development og-dev.dracodev.net) is chosen on first launch and in Configuration → Vaults & folders (Desktop).",
|
||||
"guide105.des_native": "Native system menu, optional global show/hide shortcut and a recents vault jumplist.",
|
||||
"guide105.api_intro": "ObsiGate exposes a REST API covering the whole application (vaults, files, search, backups, export, AI, sharing, admin), documented in OpenAPI 3.1:",
|
||||
"guide105.api_docs_url": "<code>/docs</code> — Swagger UI to try requests live.",
|
||||
|
||||
@@ -218,6 +218,17 @@
|
||||
"auth.session_expired": "Session expirée, veuillez vous reconnecter",
|
||||
"auth.user_deleted": "Utilisateur supprimé",
|
||||
"auth.username": "Nom d'utilisateur",
|
||||
"auth.central_login": "Se connecter avec mon compte central",
|
||||
"auth.central_unavailable": "Connexion centralisée indisponible.",
|
||||
"auth.central_starting": "Préparation de la connexion centralisée…",
|
||||
"auth.central_code": "Code à approuver sur le site central :",
|
||||
"auth.central_open": "Ouvrir la page d'approbation",
|
||||
"auth.central_cancel": "Annuler",
|
||||
"auth.central_waiting": "En attente de l'approbation…",
|
||||
"auth.central_success": "Compte central validé ({name}).",
|
||||
"auth.central_refused": "La liaison a été refusée.",
|
||||
"auth.central_expired": "La demande a expiré. Réessayez.",
|
||||
"auth.central_error": "Impossible de contacter le site central.",
|
||||
"auto.0257e77f": "🧰 Boîte ▾",
|
||||
"auto.033a9ddf": "Modèle par défaut",
|
||||
"auto.03a6e5b1": "Les opérateurs utilisés s'affichent sous forme\n de chips colorés :",
|
||||
@@ -542,6 +553,18 @@
|
||||
"desktop.add_vault": "📁 Ajouter un vault",
|
||||
"desktop.add_dir": "📂 Ajouter un dossier",
|
||||
"desktop.roots_empty": "Aucun vault ou dossier configuré.",
|
||||
"desktop.env_prod": "Production (og.dracodev.net)",
|
||||
"desktop.env_dev": "Développement (og-dev.dracodev.net)",
|
||||
"desktop.env_restarting": "Redémarrage du backend…",
|
||||
"desktop.wizard_text": "Bienvenue dans ObsiGate Desktop. Choisissez le dossier de vos vaults Obsidian et l'environnement central pour commencer.",
|
||||
"desktop.wizard_env_label": "Environnement central",
|
||||
"desktop.wizard_pick": "Choisir mon dossier",
|
||||
"desktop.wizard_later": "Plus tard",
|
||||
"config.desktop_environment": "Environnement central",
|
||||
"config.desktop_environment_desc": "Site central utilisé pour la connexion centralisée (compte central) et les liens inter-apps. Le backend desktop redémarre après le changement.",
|
||||
"config.desktop_env_prod": "Production (og.dracodev.net)",
|
||||
"config.desktop_env_dev": "Développement (og-dev.dracodev.net)",
|
||||
"config.desktop_env_saved": "Environnement enregistré. Redémarrage du backend…",
|
||||
"config.section_historique-recent-redemarrage-non-requis": "📋 Historique récent\n Redémarrage non requis",
|
||||
"config.section_indicateurs-visuels": "Indicateurs visuels",
|
||||
"config.section_intelligence-artificielle-dans-l-editeur": "🤖 Intelligence Artificielle dans l'Éditeur",
|
||||
@@ -2630,6 +2653,7 @@
|
||||
"guide105.des_get": "L'application desktop ObsiGate (Tauri) embarque le serveur Python : aucune installation de Docker nécessaire. Elle se télécharge sur la page des Releases du dépôt et se met à jour automatiquement (updater signé).",
|
||||
"guide105.des_wizard": "Au premier lancement, un assistant demande le dossier de vos vaults (ou crée un vault de démonstration). Chaque document peut être détaché en fenêtre native séparée.",
|
||||
"guide105.des_data": "Les données desktop restent dans le répertoire applicatif ; les vaults pointent sur vos dossiers existants. Toutes les fonctionnalités web (recherche, IA, partage) sont disponibles.",
|
||||
"guide105.des_central": "La connexion accepte le compte admin local ou votre compte central (approbation dans le navigateur). L'environnement central (production og.dracodev.net ou développement og-dev.dracodev.net) se choisit au premier lancement et dans Configuration → Vaults & dossiers (Desktop).",
|
||||
"guide105.des_native": "Menu système natif, raccourci global optionnel pour afficher/masquer la fenêtre et jumplist des vaults récents.",
|
||||
"guide105.api_intro": "ObsiGate expose une API REST couvrant toute l'application (vaults, fichiers, recherche, backups, export, IA, partage, admin), documentée en OpenAPI 3.1 :",
|
||||
"guide105.api_docs_url": "<code>/docs</code> — interface Swagger UI pour essayer les requêtes en direct.",
|
||||
|
||||
@@ -12879,6 +12879,111 @@ mark {
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
/* ── #230 : Configuration — environnement central (prod/dev) ─────────────── */
|
||||
.desktop-env-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.desktop-env-row label {
|
||||
font-size: 0.85rem;
|
||||
font-weight: 600;
|
||||
color: var(--text, #fff);
|
||||
}
|
||||
.desktop-env-row select {
|
||||
padding: 7px 10px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--border, #333);
|
||||
background: var(--surface2, #1a1a2e);
|
||||
color: var(--text, #fff);
|
||||
font-family: inherit;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
.desktop-env-status {
|
||||
font-size: 0.78rem;
|
||||
color: var(--text-muted, #888);
|
||||
}
|
||||
|
||||
/* ── #230 : écran de connexion — compte central (desktop) ────────────────── */
|
||||
.login-central {
|
||||
margin-top: 20px;
|
||||
padding-top: 18px;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
.login-central-btn {
|
||||
width: 100%;
|
||||
padding: 11px 18px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--accent, #818cf8);
|
||||
background: transparent;
|
||||
color: var(--accent, #818cf8);
|
||||
font-size: 0.9rem;
|
||||
font-weight: 600;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
transition: background 150ms, color 150ms;
|
||||
}
|
||||
.login-central-btn:hover:not(:disabled) {
|
||||
background: var(--accent, #818cf8);
|
||||
color: #fff;
|
||||
}
|
||||
.login-central-btn:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.login-central-hint {
|
||||
margin: 6px 0 0;
|
||||
font-size: 0.75rem;
|
||||
color: rgba(255, 255, 255, 0.45);
|
||||
text-align: center;
|
||||
}
|
||||
.login-central-panel {
|
||||
margin-top: 14px;
|
||||
padding: 14px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--border, #333);
|
||||
background: var(--surface2, #1a1a2e);
|
||||
font-size: 0.85rem;
|
||||
color: var(--text, #fff);
|
||||
}
|
||||
.login-central-code {
|
||||
margin: 8px 0 10px;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.14em;
|
||||
text-align: center;
|
||||
color: var(--accent, #818cf8);
|
||||
}
|
||||
.login-central-status {
|
||||
margin: 8px 0 0;
|
||||
font-size: 0.8rem;
|
||||
color: var(--text-muted, #888);
|
||||
}
|
||||
.login-central-status.error {
|
||||
color: var(--danger, #f87171);
|
||||
}
|
||||
.login-central-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.login-central-actions button {
|
||||
flex: 1;
|
||||
padding: 8px 10px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--border, #333);
|
||||
background: transparent;
|
||||
color: var(--text, #fff);
|
||||
font-family: inherit;
|
||||
font-size: 0.8rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
[data-theme="light"] .login-central-hint {
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
|
||||
/* MFA Disable card */
|
||||
.mfa-disable-card {
|
||||
padding: 16px; border-radius: 10px;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "obsigate",
|
||||
"version": "2.87.3",
|
||||
"version": "2.88.0",
|
||||
"description": "**Porte d'entrée web ultra-léger pour vos vaults Obsidian** — Accédez, naviguez et recherchez dans toutes vos notes Obsidian depuis n'importe quel appareil via une interface web moderne et responsive.",
|
||||
"main": "patch.js",
|
||||
"directories": {
|
||||
|
||||
@@ -152,6 +152,31 @@ ok("shouldShowWizard reflects dismissed flag via localStorage",
|
||||
|
||||
// ── crash banner ────────────────────────────────────────────────────────────
|
||||
|
||||
console.log("environment");
|
||||
{
|
||||
let called = null;
|
||||
let args = null;
|
||||
window.__TAURI__ = { core: { invoke: async (cmd, a) => {
|
||||
called = cmd; args = a;
|
||||
return { environment: "dev", agent_url: "https://agent-dev.dracodev.net",
|
||||
central_url: "https://og-dev.dracodev.net" };
|
||||
} } };
|
||||
const settings = await desktop.getDesktopSettings();
|
||||
ok("getDesktopSettings invokes get_desktop_settings", called === "get_desktop_settings");
|
||||
ok("getDesktopSettings returns central URL", settings.central_url === "https://og-dev.dracodev.net");
|
||||
const label = desktop.desktopEnvironmentLabel(settings.environment, settings.central_url);
|
||||
ok("desktopEnvironmentLabel shows og-dev", label.includes("og-dev.dracodev.net"));
|
||||
await desktop.setDesktopEnvironment("dev");
|
||||
ok("setDesktopEnvironment invokes set_desktop_environment", called === "set_desktop_environment");
|
||||
ok("setDesktopEnvironment forwards the environment", args && args.environment === "dev");
|
||||
}
|
||||
{
|
||||
delete window.__TAURI__;
|
||||
ok("getDesktopSettings degrades on web", (await desktop.getDesktopSettings()) === undefined);
|
||||
ok("openExternalUrl returns false on web",
|
||||
(await desktop.openExternalUrl("https://og.dracodev.net")) === false);
|
||||
}
|
||||
|
||||
console.log("crash banner");
|
||||
{
|
||||
delete window.__TAURI__;
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
"""Garde-fous des scripts de build desktop (BUG-126).
|
||||
|
||||
Sans dépendance : lecture texte de `desktop/build-windows.bat` et
|
||||
`desktop/build-linux.sh`, suffisante pour verrouiller les régressions qui
|
||||
rendaient l'exe Windows inutilisable (module `encodings` introuvable, runtime
|
||||
absent à côté de l'exe) et l'invite interactive du mot de passe updater.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
DESKTOP = Path(__file__).resolve().parent.parent / "desktop"
|
||||
WINDOWS_SCRIPT = DESKTOP / "build-windows.bat"
|
||||
LINUX_SCRIPT = DESKTOP / "build-linux.sh"
|
||||
|
||||
|
||||
def _read(path: Path) -> str:
|
||||
return path.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_windows_pth_is_written_explicitly() -> None:
|
||||
"""`python311._pth` doit contenir stdlib + site + racine de l'exe.
|
||||
|
||||
L'ancien script ajoutait deux lignes au fichier de l'archive ; un état
|
||||
partiel (ou un fichier déjà réécrit) laissait un `_pth` sans
|
||||
`python311.zip` ni `.` → `ModuleNotFoundError: No module named
|
||||
'encodings'`, backend mort, interface sans CSS.
|
||||
"""
|
||||
script = _read(WINDOWS_SCRIPT)
|
||||
|
||||
assert "echo python311.zip" in script
|
||||
assert "echo import site" in script
|
||||
assert "echo .." in script
|
||||
assert ">> python-embed\\python311._pth" not in script
|
||||
assert ">> \"%OUTDIR%\\python-embed\\python311._pth\"" not in script
|
||||
|
||||
|
||||
def test_windows_copies_full_runtime_next_to_exe() -> None:
|
||||
"""L'exe résout `python-embed/`, `backend/` et `frontend/` à côté de lui."""
|
||||
script = _read(WINDOWS_SCRIPT)
|
||||
|
||||
assert "for %%D in (python-embed backend frontend) do" in script
|
||||
assert "xcopy /E /I /Q /Y \"%%D\" \"%OUTDIR%\\%%D\"" in script
|
||||
|
||||
|
||||
def test_windows_runs_from_script_directory() -> None:
|
||||
"""Un appel `desktop\\build-windows.bat` ne doit pas nettoyer le dépôt."""
|
||||
script = _read(WINDOWS_SCRIPT).lower()
|
||||
assert 'cd /d "%~dp0"' in script
|
||||
# Un exe encore lancé verrouille sa cible (Access is denied) : le build
|
||||
# doit fermer l'application avant de recompiler.
|
||||
assert "taskkill /f /im obsigate-desktop.exe" in script
|
||||
|
||||
|
||||
def test_windows_verifies_runtime_before_building() -> None:
|
||||
script = _read(WINDOWS_SCRIPT)
|
||||
|
||||
assert 'if not exist "python-embed\\python.exe"' in script
|
||||
assert "import encodings, uvicorn, fastapi, pyotp" in script
|
||||
|
||||
|
||||
def test_updater_signing_is_opt_in_without_password_prompt() -> None:
|
||||
"""Pas de `.sig` et aucune invite si le mot de passe n'est pas fourni."""
|
||||
windows = _read(WINDOWS_SCRIPT)
|
||||
linux = _read(LINUX_SCRIPT)
|
||||
|
||||
for script in (windows, linux):
|
||||
assert "TAURI_SIGNING_PRIVATE_KEY_PASSWORD" in script
|
||||
assert "TAURI_SIGNING_PRIVATE_KEY_PATH" in script
|
||||
assert "--ci" in script
|
||||
|
||||
assert "set /p TAURI_SIGNING_PRIVATE_KEY=" not in windows
|
||||
@@ -0,0 +1,211 @@
|
||||
# tests/test_desktop_sso.py
|
||||
# Desktop #230 — connexion avec un compte central : le backend embarqué
|
||||
# démarre une liaison d'appareil sur le site central choisi, valide le jeton
|
||||
# draco (via /api/auth/me du central) puis ouvre la session de l'admin local.
|
||||
# Toutes les routes sont inertes (404) hors du shell desktop.
|
||||
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from fastapi import HTTPException
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from backend.auth.password import hash_password
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def desktop_client(tmp_path, monkeypatch):
|
||||
"""Application réelle, données isolées, mode desktop + admin local."""
|
||||
data_dir = tmp_path / "data"
|
||||
data_dir.mkdir()
|
||||
users = {
|
||||
"version": 1,
|
||||
"users": {
|
||||
"admin": {
|
||||
"id": "admin-1",
|
||||
"username": "admin",
|
||||
"display_name": "Admin local",
|
||||
"password_hash": hash_password("chab30"),
|
||||
"role": "admin",
|
||||
"vaults": ["*"],
|
||||
"active": True,
|
||||
"created_at": "2026-01-01T00:00:00",
|
||||
}
|
||||
},
|
||||
}
|
||||
(data_dir / "users.json").write_text(json.dumps(users), encoding="utf-8")
|
||||
src_secret = Path("data/secret.key")
|
||||
if src_secret.exists():
|
||||
shutil.copy2(str(src_secret), str(data_dir / "secret.key"))
|
||||
|
||||
orig_cwd = os.getcwd()
|
||||
os.chdir(str(tmp_path))
|
||||
monkeypatch.setenv("OBSIGATE_AUTH_ENABLED", "true")
|
||||
monkeypatch.setenv("OBSIGATE_ADMIN_USER", "admin")
|
||||
monkeypatch.setenv("OBSIGATE_ADMIN_PASSWORD", "chab30")
|
||||
monkeypatch.setenv("OBSIGATE_WATCHER_ENABLED", "false")
|
||||
monkeypatch.setenv("OBSIGATE_DESKTOP_SSO", "1")
|
||||
monkeypatch.setenv("OBSIGATE_DESKTOP_ENV", "dev")
|
||||
monkeypatch.setenv("DRACO_OBSIGATE_URL", "https://og-dev.dracodev.net")
|
||||
|
||||
import backend.main
|
||||
backend.main._load_config = lambda: {"watcher_enabled": False}
|
||||
from backend.main import app
|
||||
|
||||
client = TestClient(app)
|
||||
yield client
|
||||
os.chdir(orig_cwd)
|
||||
|
||||
|
||||
def test_desktop_sso_disabled_returns_404(desktop_client, monkeypatch):
|
||||
monkeypatch.delenv("OBSIGATE_DESKTOP_SSO", raising=False)
|
||||
assert desktop_client.get("/api/desktop/sso/status").status_code == 404
|
||||
assert desktop_client.post("/api/desktop/sso/start").status_code == 404
|
||||
|
||||
|
||||
def test_status_reports_environment(desktop_client):
|
||||
res = desktop_client.get("/api/desktop/sso/status")
|
||||
assert res.status_code == 200
|
||||
body = res.json()
|
||||
assert body["enabled"] is True
|
||||
assert body["environment"] == "dev"
|
||||
assert body["central_url"] == "https://og-dev.dracodev.net"
|
||||
|
||||
|
||||
def test_start_rejects_foreign_browser_origin(desktop_client):
|
||||
res = desktop_client.post(
|
||||
"/api/desktop/sso/start",
|
||||
headers={"Origin": "https://evil.example"},
|
||||
)
|
||||
assert res.status_code == 403
|
||||
|
||||
|
||||
def test_start_delegates_to_central_liaison(desktop_client, monkeypatch):
|
||||
from backend.routers import desktop_sso
|
||||
|
||||
calls = {}
|
||||
|
||||
def fake_post(path, payload):
|
||||
calls["path"] = path
|
||||
calls["payload"] = payload
|
||||
return {
|
||||
"demande_id": "d1",
|
||||
"code_utilisateur": "ABCD-2345",
|
||||
"code_appareil": "secret",
|
||||
"expire_dans_s": 600,
|
||||
"url_liaison": "/liaison?code=ABCD-2345",
|
||||
# Le central derrière un proxy peut renvoyer http:// : le pont
|
||||
# desktop reconstruit toujours l'URL sur le site configuré (https).
|
||||
"url_liaison_absolue":
|
||||
"http://og-dev.dracodev.net/liaison?code=ABCD-2345",
|
||||
}
|
||||
|
||||
monkeypatch.setattr(desktop_sso, "_central_post", fake_post)
|
||||
res = desktop_client.post("/api/desktop/sso/start")
|
||||
assert res.status_code == 200
|
||||
body = res.json()
|
||||
assert body["code_utilisateur"] == "ABCD-2345"
|
||||
assert body["url_liaison_absolue"] == (
|
||||
"https://og-dev.dracodev.net/liaison?code=ABCD-2345")
|
||||
assert calls["path"] == "/api/v1/liaison"
|
||||
assert calls["payload"]["type"] == "desktop"
|
||||
assert "ObsiGate Desktop" in calls["payload"]["nom"]
|
||||
|
||||
|
||||
def test_poll_pending_returns_status(desktop_client, monkeypatch):
|
||||
from backend.routers import desktop_sso
|
||||
|
||||
monkeypatch.setattr(
|
||||
desktop_sso, "_central_post",
|
||||
lambda path, payload: {"statut": "en_attente"},
|
||||
)
|
||||
res = desktop_client.post("/api/desktop/sso/poll", json={
|
||||
"demande_id": "d1", "code_appareil": "secret",
|
||||
})
|
||||
assert res.status_code == 200
|
||||
assert res.json() == {"statut": "en_attente"}
|
||||
|
||||
|
||||
def test_poll_approved_opens_local_admin(desktop_client, monkeypatch):
|
||||
from backend.routers import desktop_sso
|
||||
|
||||
validated = {}
|
||||
|
||||
def fake_post(path, payload):
|
||||
return {"statut": "approuvee", "jeton": "draco-token"}
|
||||
|
||||
def fake_me(token):
|
||||
validated["token"] = token
|
||||
return {"username": "bruno", "display_name": "Bruno",
|
||||
"role": "admin"}
|
||||
|
||||
monkeypatch.setattr(desktop_sso, "_central_post", fake_post)
|
||||
monkeypatch.setattr(desktop_sso, "_central_me", fake_me)
|
||||
|
||||
res = desktop_client.post("/api/desktop/sso/poll", json={
|
||||
"demande_id": "d1", "code_appareil": "secret", "remember_me": True,
|
||||
})
|
||||
assert res.status_code == 200
|
||||
body = res.json()
|
||||
assert validated["token"] == "draco-token"
|
||||
assert body["statut"] == "approuvee"
|
||||
assert body["user"]["username"] == "admin"
|
||||
assert body["central_user"]["username"] == "bruno"
|
||||
assert body["access_token"]
|
||||
assert "access_token" in res.cookies
|
||||
assert "refresh_token" in res.cookies
|
||||
|
||||
|
||||
def test_poll_central_refusal_is_relayed(desktop_client, monkeypatch):
|
||||
from backend.routers import desktop_sso
|
||||
|
||||
monkeypatch.setattr(
|
||||
desktop_sso, "_central_post",
|
||||
lambda path, payload: {"statut": "approuvee", "jeton": "x"},
|
||||
)
|
||||
|
||||
def refuse(token):
|
||||
raise HTTPException(status_code=403, detail="rôle « aucun »")
|
||||
|
||||
monkeypatch.setattr(desktop_sso, "_central_me", refuse)
|
||||
res = desktop_client.post("/api/desktop/sso/poll", json={
|
||||
"demande_id": "d1", "code_appareil": "secret",
|
||||
})
|
||||
assert res.status_code == 403
|
||||
assert "aucun" in res.json()["detail"]
|
||||
|
||||
|
||||
def test_central_url_rejects_unknown_host(desktop_client, monkeypatch):
|
||||
from backend.routers import desktop_sso
|
||||
|
||||
monkeypatch.setenv("DRACO_OBSIGATE_URL", "https://evil.example")
|
||||
with pytest.raises(HTTPException) as exc:
|
||||
desktop_sso.central_url()
|
||||
assert exc.value.status_code == 503
|
||||
|
||||
|
||||
def test_local_admin_prefers_admin_username(tmp_path, monkeypatch):
|
||||
from backend.routers import desktop_sso
|
||||
|
||||
data_dir = tmp_path / "data"
|
||||
data_dir.mkdir()
|
||||
(data_dir / "users.json").write_text(json.dumps({
|
||||
"version": 1,
|
||||
"users": {
|
||||
"boss": {"id": "1", "username": "boss", "role": "admin",
|
||||
"vaults": ["*"], "active": True,
|
||||
"display_name": "Boss"},
|
||||
"alice": {"id": "2", "username": "alice", "role": "user",
|
||||
"vaults": [], "active": True, "display_name": "Alice"},
|
||||
},
|
||||
}), encoding="utf-8")
|
||||
orig_cwd = os.getcwd()
|
||||
os.chdir(str(tmp_path))
|
||||
try:
|
||||
monkeypatch.setenv("OBSIGATE_ADMIN_USER", "admin")
|
||||
assert desktop_sso._local_admin()["username"] == "boss"
|
||||
finally:
|
||||
os.chdir(orig_cwd)
|
||||
@@ -0,0 +1,46 @@
|
||||
"""Garde-fous UI — desktop #230 (compte central + environnement).
|
||||
|
||||
Vérifie que le pont desktop reste conditionné à ``isTauriEnv()`` (aucun
|
||||
impact web) et que les deux environnements (prod/dev) sont exposés dans la
|
||||
Configuration et le premier lancement. Le comportement serveur est couvert
|
||||
par ``tests/test_desktop_sso.py`` et les tests Rust.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
FRONTEND = Path(__file__).resolve().parent.parent / "frontend"
|
||||
|
||||
|
||||
def _read(*parts: str) -> str:
|
||||
return (FRONTEND.joinpath(*parts)).read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_auth_exposes_desktop_central_login():
|
||||
auth_js = _read("js", "auth.js")
|
||||
assert "initDesktopCentralLogin" in auth_js
|
||||
assert "if (!isTauriEnv()) return;" in auth_js
|
||||
assert "/api/desktop/sso/start" in auth_js
|
||||
assert "/api/desktop/sso/poll" in auth_js
|
||||
# Le login local reste le chemin par défaut.
|
||||
assert 'fetch("/api/auth/login"' in auth_js
|
||||
|
||||
|
||||
def test_desktop_bridge_exposes_environment_commands():
|
||||
desktop_js = _read("js", "desktop.js")
|
||||
assert "get_desktop_settings" in desktop_js
|
||||
assert "set_desktop_environment" in desktop_js
|
||||
assert "export async function getDesktopSettings" in desktop_js
|
||||
assert "export async function setDesktopEnvironment" in desktop_js
|
||||
assert "export async function openExternalUrl" in desktop_js
|
||||
|
||||
|
||||
def test_config_section_has_environment_selector():
|
||||
index = _read("index.html")
|
||||
assert 'id="cfg-desktop-environment"' in index
|
||||
assert 'id="cfg-desktop-environment-status"' in index
|
||||
|
||||
|
||||
def test_first_run_wizard_has_environment_selector():
|
||||
desktop_js = _read("js", "desktop.js")
|
||||
assert "desktop-wizard-environment" in desktop_js
|
||||
assert "desktop.wizard_env_label" in desktop_js
|
||||
@@ -191,6 +191,16 @@ def test_retour_sso_refresh_force_bug_125():
|
||||
assert auth_js.count("if (this._honorReturnTo()) return true;") == 2
|
||||
|
||||
|
||||
def test_retour_liaison_meme_hote_230():
|
||||
# #230 : la page publique /liaison renvoie vers elle-même après le
|
||||
# login central (`return_to` même hôte). Le desktop en a besoin pour
|
||||
# reprendre l'approbation d'appareil ; les autres retours même-hôte
|
||||
# restent ignorés (pas de boucle).
|
||||
auth_js = (FRONTEND / "js" / "auth.js").read_text(encoding="utf-8")
|
||||
assert 'u.pathname.startsWith("/liaison")' in auth_js
|
||||
assert "(!sameHost || sameHostLiaison)" in auth_js
|
||||
|
||||
|
||||
def test_panneau_spark_integre_218():
|
||||
# #218 : le bouton Spark de la barre ouvre le panneau de l'agent
|
||||
# commun (mêmes assets partagés que TikTak / Flowdeck / Kanbante).
|
||||
|
||||
Reference in New Issue
Block a user