Compare commits
15 Commits
docs/ops-m
...
docs/runbo
| Author | SHA1 | Date | |
|---|---|---|---|
| cab9e9cf2d | |||
| 010601be63 | |||
| add688602a | |||
| 3f3c717185 | |||
| b5f32da0c8 | |||
| 6e7ed8e041 | |||
| 90f79a7ee7 | |||
| b5663891a1 | |||
| a74b95e775 | |||
| b78eb4fc7b | |||
| 80c047369f | |||
| d7c158a0fc | |||
| 30f0ef4164 | |||
| d2963673c9 | |||
| d59e10dfc6 |
3
.env
3
.env
@@ -1,3 +0,0 @@
|
|||||||
PUBLIC_GITEA_BASE=https://gitea.archicratie.trans-hands.synology.me
|
|
||||||
PUBLIC_GITEA_OWNER=Archicratia
|
|
||||||
PUBLIC_GITEA_REPO=archicratie-edition
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
PUBLIC_GITEA_BASE=https://gitea.archicratie.trans-hands.synology.me
|
|
||||||
PUBLIC_GITEA_OWNER=Archicratia
|
|
||||||
PUBLIC_GITEA_REPO=archicratie-edition
|
|
||||||
PUBLIC_SITE=https://archicratie.trans-hands.synology.me
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
FORGE_API=http://192.168.1.20:3000
|
|
||||||
FORGE_BASE=https://gitea.archicratie.trans-hands.synology.me
|
|
||||||
FORGE_TOKEN=aW73wpfJ4MiN2!3UU69qL*vWF9$9V7f@2
|
|
||||||
PUBLIC_GITEA_OWNER=Archicratia
|
|
||||||
PUBLIC_GITEA_REPO=archicratie-edition
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
PUBLIC_SITE=https://archicratie.trans-hands.synology.me
|
|
||||||
PUBLIC_RELEASE=0.1.0
|
|
||||||
|
|
||||||
PUBLIC_GITEA_BASE=https://gitea.archicratie.trans-hands.synology.me
|
|
||||||
PUBLIC_GITEA_OWNER=Archicratia
|
|
||||||
PUBLIC_GITEA_REPO=archicratie-edition
|
|
||||||
@@ -10,6 +10,15 @@ Si un seul de ces 3 paramètres est faux → on obtient :
|
|||||||
- 404 / redirect login inattendu
|
- 404 / redirect login inattendu
|
||||||
- ou un repo/owner incorrect
|
- ou un repo/owner incorrect
|
||||||
|
|
||||||
|
|
||||||
|
# Diagnostic — “Proposer” (résumé)
|
||||||
|
|
||||||
|
**Symptôme :** clic “Proposer” → 404 / login / mauvais repo
|
||||||
|
**Cause la plus fréquente :** `PUBLIC_GITEA_OWNER` (casse sensible) ou `PUBLIC_GITEA_REPO` faux.
|
||||||
|
|
||||||
|
➡️ Procédure complète (pas-à-pas + commandes) : voir `docs/TROUBLESHOOTING.md#proposer-404`.
|
||||||
|
|
||||||
|
|
||||||
## 1) Variables utilisées (publique, côté build Astro)
|
## 1) Variables utilisées (publique, côté build Astro)
|
||||||
|
|
||||||
- `PUBLIC_GITEA_BASE`
|
- `PUBLIC_GITEA_BASE`
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
# Déploiement production (Synology DS220+ / DSM 7.3) — Astro → Nginx statique
|
# Déploiement production (Synology DS220+ / DSM 7.3) — Astro → Nginx statique
|
||||||
|
|
||||||
|
> ✅ **CANONIQUE** — Procédure de référence “prod DS220+ / DSM 7.3”.
|
||||||
|
|
||||||
|
> Toute modif de déploiement doit être faite **ici**, via PR sur Gitea/main (pas d’édition à la main en prod).
|
||||||
|
|
||||||
|
> Périmètre : build Docker (Node→Nginx), blue/green 8081/8082, Reverse Proxy DSM, smoke, rollback.
|
||||||
|
|
||||||
|
> Dépendances critiques : variables PUBLIC_GITEA_* (sinon “Proposer” part en 404/login loop).
|
||||||
|
|
||||||
|
> Voir aussi : OPS-REFERENCE.md (index), OPS_COCKPIT.md (checklist), TROUBLESHOOTING.md (incidents).
|
||||||
|
|
||||||
Dernière mise à jour : 2026-02-01
|
Dernière mise à jour : 2026-02-01
|
||||||
|
|
||||||
Ce document décrit une mise en place stable sur NAS :
|
Ce document décrit une mise en place stable sur NAS :
|
||||||
@@ -73,6 +83,17 @@ for f in .env .env.local .env.production .env.production.local; do
|
|||||||
[ -f "$f" ] && echo "---- $f" && grep -nE '^PUBLIC_GITEA_(BASE|OWNER|REPO)=' "$f" || true
|
[ -f "$f" ] && echo "---- $f" && grep -nE '^PUBLIC_GITEA_(BASE|OWNER|REPO)=' "$f" || true
|
||||||
done
|
done
|
||||||
|
|
||||||
|
En cas d’échec :
|
||||||
|
- 404 / login loop / mauvais repo → `docs/TROUBLESHOOTING.md#proposer-404`
|
||||||
|
- double onglet → `docs/TROUBLESHOOTING.md#proposer-double-onglet`
|
||||||
|
|
||||||
|
## Diagnostic — “Proposer” (résumé)
|
||||||
|
|
||||||
|
**Symptôme :** clic “Proposer” → 404 / login / mauvais repo
|
||||||
|
**Cause la plus fréquente :** `PUBLIC_GITEA_OWNER` (casse sensible) ou `PUBLIC_GITEA_REPO` faux.
|
||||||
|
|
||||||
|
➡️ Procédure complète (pas-à-pas + commandes) : voir `docs/TROUBLESHOOTING.md#proposer-404`.
|
||||||
|
|
||||||
## 5) Reverse Proxy DSM (le point clé)
|
## 5) Reverse Proxy DSM (le point clé)
|
||||||
|
|
||||||
### DSM 7.3 :
|
### DSM 7.3 :
|
||||||
|
|||||||
@@ -43,61 +43,15 @@ Le flow ne doit jamais ouvrir deux onglets.
|
|||||||
- un seul `a.target="_blank"` (ou équivalent) déclenché
|
- un seul `a.target="_blank"` (ou équivalent) déclenché
|
||||||
- sur click : handler doit neutraliser les propagations parasites
|
- sur click : handler doit neutraliser les propagations parasites
|
||||||
|
|
||||||
### Vérification (NAS)
|
## Diagnostic (canonique)
|
||||||
en sh :
|
|
||||||
curl -fsS http://127.0.0.1:8082/archicratie/archicrat-ia/chapitre-4/ > /tmp/page.html
|
|
||||||
grep -n "window.open" /tmp/page.html | head
|
|
||||||
|
|
||||||
Doit retourner 0 ligne.
|
Le diagnostic détaillé est centralisé dans `docs/TROUBLESHOOTING.md` pour éviter les doublons.
|
||||||
|
|
||||||
## 3) Diagnostic “trace ouverture onglet” (navigateur)
|
- 404 / non autorisé / redirect login :
|
||||||
|
- voir : `TROUBLESHOOTING.md#proposer-404`
|
||||||
|
- cause la plus fréquente : `PUBLIC_GITEA_OWNER/REPO` faux (souvent casse)
|
||||||
|
|
||||||
Dans la console, tu peux surcharger temporairement les mécanismes d’ouverture pour tracer :
|
- Double onglet :
|
||||||
|
- voir : `TROUBLESHOOTING.md#proposer-double-onglet`
|
||||||
|
- cause la plus fréquente : double handler (bubbling) ou `window.open` + `a.click()`
|
||||||
|
|
||||||
si un window.open survient,
|
|
||||||
|
|
||||||
ou si un a.click target _blank est appelé.
|
|
||||||
|
|
||||||
But : prouver qu’il n’y a qu’un seul événement d’ouverture.
|
|
||||||
|
|
||||||
## 4) URL attendue (forme)
|
|
||||||
|
|
||||||
L’onglet doit ressembler à :
|
|
||||||
|
|
||||||
{PUBLIC_GITEA_BASE}/{OWNER}/{REPO}/issues/new?title=...&body=...
|
|
||||||
|
|
||||||
Important : owner et repo doivent être exactement ceux du repo canonique.
|
|
||||||
|
|
||||||
## 5) Pré-requis d’accès
|
|
||||||
|
|
||||||
L’utilisateur doit être loggé sur Gitea pour accéder à /issues/new
|
|
||||||
|
|
||||||
Si non loggé : redirect vers /user/login (comportement normal)
|
|
||||||
|
|
||||||
## 6) Tests fonctionnels (checklist)
|
|
||||||
|
|
||||||
Ouvrir une page chapitre (ex chapitre 4)
|
|
||||||
|
|
||||||
Clic Proposer (sur un paragraphe)
|
|
||||||
|
|
||||||
Choix 1 puis choix 2
|
|
||||||
|
|
||||||
Vérifier :
|
|
||||||
|
|
||||||
1 seul onglet
|
|
||||||
|
|
||||||
URL du repo correct
|
|
||||||
|
|
||||||
formulaire new issue visible
|
|
||||||
|
|
||||||
title/body pré-remplis (chemin + ancre + texte actuel)
|
|
||||||
|
|
||||||
Créer l’issue → vérifier le traitement CI/runner
|
|
||||||
|
|
||||||
## 7) Pannes typiques + causes
|
|
||||||
|
|
||||||
404 sur issue/new : PUBLIC_GITEA_OWNER/REPO faux (souvent casse)
|
|
||||||
|
|
||||||
2 onglets : double handler (bubbling + ouverture multiple)
|
|
||||||
|
|
||||||
pas de favicon : cache ou absence dans public/ → rebuild
|
|
||||||
|
|||||||
@@ -1,6 +1,46 @@
|
|||||||
OPS — Déploiement Archicratie Web Edition (Mac Studio → DS220+)
|
# OPS — Déploiement Archicratie Web Edition (Mac Studio → DS220+)
|
||||||
Objectif : déployer une nouvelle version du site sur le NAS (DS220+) sans jamais casser la prod, en utilisant un schéma blue/green piloté par DSM Reverse Proxy, avec une procédure robuste même quand docker compose build est instable sur le NAS.
|
Objectif : déployer une nouvelle version du site sur le NAS (DS220+) sans jamais casser la prod, en utilisant un schéma blue/green piloté par DSM Reverse Proxy, avec une procédure robuste même quand docker compose build est instable sur le NAS.
|
||||||
|
|
||||||
|
> 🟧 **LEGACY / HISTORIQUE** — Ce document n’est plus la source de vérité.
|
||||||
|
|
||||||
|
> Référence actuelle : docs/DEPLOY_PROD_SYNOLOGY_DS220.md (canonique).
|
||||||
|
|
||||||
|
> Statut : gelé (on n’édite plus que pour ajouter un lien vers le canonique, si nécessaire).
|
||||||
|
|
||||||
|
> Raison : doublon → risque de divergence → risque d’erreur en prod.
|
||||||
|
|
||||||
|
> Si tu lis ceci pour déployer : stop → ouvre le canonique.
|
||||||
|
|
||||||
|
> ⚠️ LEGACY — Ne pas suivre pour déployer.
|
||||||
|
> Doc conservé pour historique.
|
||||||
|
> Canon : `DEPLOY_PROD_SYNOLOGY_DS220.md` + `OPS-SYNC-TRIPLE-SOURCE.md`.
|
||||||
|
|
||||||
|
## Pourquoi ce doc existe encore
|
||||||
|
|
||||||
|
- Historique : il capture des repères (domaines, ports, logique blue/green) tels qu’ils ont été consolidés pendant la phase d’implémentation.
|
||||||
|
- Sécurité : éviter la divergence documentaire (un seul pas-à-pas officiel).
|
||||||
|
- Maintenance : si tu dois déployer, tu suis le canonique ; ici tu ne viens que pour comprendre “d’où ça vient”.
|
||||||
|
|
||||||
|
## Ce qu’il faut faire aujourd’hui (canonique)
|
||||||
|
|
||||||
|
➡️ Déploiement = `docs/DEPLOY_PROD_SYNOLOGY_DS220.md` (procédure détaillée, à jour).
|
||||||
|
|
||||||
|
## Schéma (résumé, sans commandes)
|
||||||
|
|
||||||
|
- Ne jamais toucher au slot live.
|
||||||
|
- Construire/tester sur l’autre slot.
|
||||||
|
- Smoke test.
|
||||||
|
- Bascule DSM Reverse Proxy (8081 ↔ 8082).
|
||||||
|
- Rollback DSM si besoin.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
> 🚫 NE PAS UTILISER POUR PROD — ARCHIVE UNIQUEMENT
|
||||||
|
|
||||||
|
<summary>Archive — ancien pas-à-pas (NE PAS SUIVRE)</summary>
|
||||||
|
|
||||||
|
> ⚠️ Archive. Ce contenu est conservé pour mémoire.
|
||||||
|
|
||||||
## 0) Repères essentiels
|
## 0) Repères essentiels
|
||||||
Noms & domaines
|
Noms & domaines
|
||||||
• Site public (prod) : https://archicratie.trans-hands.synology.me
|
• Site public (prod) : https://archicratie.trans-hands.synology.me
|
||||||
@@ -383,3 +423,5 @@ Fix standard (dans le vrai dossier site/) :
|
|||||||
rm -rf node_modules .astro dist
|
rm -rf node_modules .astro dist
|
||||||
npm ci
|
npm ci
|
||||||
npm run dev
|
npm run dev
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Document “pivot” : liens, invariants, conventions, commandes réflexes.
|
|||||||
|
|
||||||
## 0) Invariants (à ne pas casser)
|
## 0) Invariants (à ne pas casser)
|
||||||
|
|
||||||
- **Source de vérité Git** : `origin/main` sur :contentReference[oaicite:0]{index=0}.
|
- **Source de vérité Git** : origin/main (repo Archicratia/archicratie-edition sur Gitea).
|
||||||
- **Prod** : conteneur `archicratie-web-*` (nginx) derrière reverse proxy DSM.
|
- **Prod** : conteneur `archicratie-web-*` (nginx) derrière reverse proxy DSM.
|
||||||
- **Config “Proposer”** : dépend de `PUBLIC_GITEA_BASE`, `PUBLIC_GITEA_OWNER`, `PUBLIC_GITEA_REPO` injectés au build.
|
- **Config “Proposer”** : dépend de `PUBLIC_GITEA_BASE`, `PUBLIC_GITEA_OWNER`, `PUBLIC_GITEA_REPO` injectés au build.
|
||||||
- **Branches** : `main` = travail ; `master` = legacy/compat (alignée mais protégée).
|
- **Branches** : `main` = travail ; `master` = legacy/compat (alignée mais protégée).
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
# OPS Runbook — Archicratie Web (NAS Synology DS220 + Gitea)
|
# OPS Runbook — Archicratie Web (NAS Synology DS220 + Gitea)
|
||||||
|
|
||||||
|
> 🟦 **ALIAS (résumé)** — Runbook 1-page pour opérer vite sans se tromper.
|
||||||
|
|
||||||
|
> La procédure détaillée **canonique** est : docs/DEPLOY_PROD_SYNOLOGY_DS220.md.
|
||||||
|
|
||||||
|
> Source Git : Gitea/main ; déploiement = rebuild depuis main ; pas de hotfix non versionné.
|
||||||
|
|
||||||
|
> Déploiement : build sur slot inactif → smoke → bascule DSM → rollback si besoin.
|
||||||
|
|
||||||
|
> Incidents connus : voir docs/TROUBLESHOOTING.md.
|
||||||
|
|
||||||
## 0. Objectif
|
## 0. Objectif
|
||||||
Ce document décrit la procédure **exacte** pour :
|
Ce document décrit la procédure **exacte** pour :
|
||||||
- maintenir un état cohérent entre **Local (Mac Studio)**, **Gitea**, **NAS (prod)** ;
|
- maintenir un état cohérent entre **Local (Mac Studio)**, **Gitea**, **NAS (prod)** ;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ Toujours isoler : **Local**, **Gitea**, **NAS**, **Navigateur**.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
<a id="proposer-404"></a>
|
||||||
## 1) “Proposer” ouvre Gitea mais retourne 404 / non autorisé
|
## 1) “Proposer” ouvre Gitea mais retourne 404 / non autorisé
|
||||||
|
|
||||||
### Symptôme
|
### Symptôme
|
||||||
@@ -38,6 +39,7 @@ Puis rebuild + restart du container + smoke.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
<a id="proposer-double-onglet"></a>
|
||||||
## 2) Double onglet à la validation du flow “Proposer”
|
## 2) Double onglet à la validation du flow “Proposer”
|
||||||
|
|
||||||
### Symptôme
|
### Symptôme
|
||||||
@@ -64,7 +66,9 @@ garder un seul mécanisme d’ouverture
|
|||||||
|
|
||||||
sur click : preventDefault() + stopImmediatePropagation()
|
sur click : preventDefault() + stopImmediatePropagation()
|
||||||
|
|
||||||
|
<a id="Favicon-504-erreurs"></a>
|
||||||
## 3) Favicon 504 / erreurs console sur favicon
|
## 3) Favicon 504 / erreurs console sur favicon
|
||||||
|
|
||||||
# Symptôme
|
# Symptôme
|
||||||
|
|
||||||
Console navigateur : GET /favicon.ico 504
|
Console navigateur : GET /favicon.ico 504
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ Si l’ID exact n’existe plus :
|
|||||||
But : éviter les “liens morts” historiques quand une régénération d’IDs a eu lieu.
|
But : éviter les “liens morts” historiques quand une régénération d’IDs a eu lieu.
|
||||||
|
|
||||||
Limite : c’est un fallback de dernier recours (moins déterministe qu’un alias explicite).
|
Limite : c’est un fallback de dernier recours (moins déterministe qu’un alias explicite).
|
||||||
Le mécanisme recommandé reste : `docs/anchor-aliases.json` + injection au build.
|
Le mécanisme recommandé reste : `src/anchors/anchor-aliases.json` + injection au build.
|
||||||
|
|
||||||
_______________________________________
|
_______________________________________
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ Les IDs d’ancres générés (ou dérivés) peuvent changer :
|
|||||||
|
|
||||||
## 2) Le mapping d’alias
|
## 2) Le mapping d’alias
|
||||||
|
|
||||||
- Fichier versionné (ex) : `docs/anchor-aliases.json`
|
- Fichier versionné (ex) : `src/anchors/anchor-aliases.json`
|
||||||
- Format : `oldId -> newId` par page
|
- Format : `oldId -> newId` par page
|
||||||
|
|
||||||
Ex en json :
|
Ex en json :
|
||||||
|
|||||||
201
docs/auth-stack.md
Normal file
201
docs/auth-stack.md
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
# Auth Stack — LLDAP + Authelia + Redis (DSM 7.3 / Synology DS220+)
|
||||||
|
|
||||||
|
## Objectif
|
||||||
|
Fournir une pile d’authentification robuste (anti-lockout) pour protéger des services web via reverse-proxy :
|
||||||
|
- Annuaire utilisateurs : **LLDAP**
|
||||||
|
- Portail / SSO / MFA : **Authelia**
|
||||||
|
- Cache/sessions (optionnel selon config) : **Redis**
|
||||||
|
- Exposition publique : **Reverse proxy** (Synology / Nginx / Traefik) vers Authelia
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
### Composants
|
||||||
|
- **LLDAP**
|
||||||
|
- UI admin (HTTP) : `127.0.0.1:17170`
|
||||||
|
- LDAP : `127.0.0.1:3890`
|
||||||
|
- Base : sqlite dans `/volume2/docker/auth/data/lldap`
|
||||||
|
|
||||||
|
- **Authelia**
|
||||||
|
- API/portal : `127.0.0.1:9091`
|
||||||
|
- Stockage : sqlite dans `/volume2/docker/auth/data/authelia/db.sqlite3`
|
||||||
|
- Accès externe : via reverse proxy -> `https://auth.<domaine>`
|
||||||
|
|
||||||
|
- **Redis**
|
||||||
|
- Local uniquement : `127.0.0.1:6379`
|
||||||
|
- (peut servir plus tard à sessions/rate-limit selon config)
|
||||||
|
|
||||||
|
### Exposition réseau (principe de sécurité)
|
||||||
|
- Tous les services **bindés sur 127.0.0.1** (loopback NAS)
|
||||||
|
- Seul le **reverse proxy** expose `https://auth.<domaine>` vers `127.0.0.1:9091`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Fichiers de référence
|
||||||
|
|
||||||
|
### 1) docker-compose.auth.yml
|
||||||
|
- Déploie redis + lldap + authelia.
|
||||||
|
- Recommandation DSM : **network_mode: host** + bind sur localhost.
|
||||||
|
- Supprime les aléas “bridge + DNS + subnets”
|
||||||
|
- Évite les timeouts LDAP sporadiques.
|
||||||
|
|
||||||
|
### 2) /volume2/docker/auth/compose/.env
|
||||||
|
Variables attendues :
|
||||||
|
|
||||||
|
#### LLDAP
|
||||||
|
- `LLDAP_JWT_SECRET=...` (random 32+)
|
||||||
|
- `LLDAP_KEY_SEED=...` (random 32+)
|
||||||
|
- `LLDAP_LDAP_USER_PASS=...` (mot de passe admin LLDAP)
|
||||||
|
|
||||||
|
#### Authelia
|
||||||
|
- `AUTHELIA_JWT_SECRET=...` (utilisé ici comme source pour reset_password)
|
||||||
|
- `AUTHELIA_SESSION_SECRET=...`
|
||||||
|
- `AUTHELIA_STORAGE_ENCRYPTION_KEY=...`
|
||||||
|
|
||||||
|
> Ne jamais committer `.env`. Stocker dans DSM / secrets.
|
||||||
|
|
||||||
|
### 3) /volume2/docker/auth/config/authelia/configuration.yml
|
||||||
|
- LDAP address en mode robuste : `ldap://127.0.0.1:3890`
|
||||||
|
- Cookie domain : `archicratie.trans-hands.synology.me`
|
||||||
|
- `authelia_url` : `https://auth.archicratie.trans-hands.synology.me`
|
||||||
|
- `default_redirection_url` : service principal (ex: gitea)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Procédures opératoires
|
||||||
|
|
||||||
|
### Restart safe (redémarrage propre)
|
||||||
|
en bash :
|
||||||
|
cd /volume2/docker/auth/compose
|
||||||
|
sudo docker compose --env-file .env -f docker-compose.auth.yml down --remove-orphans
|
||||||
|
sudo docker compose --env-file .env -f docker-compose.auth.yml up -d --force-recreate
|
||||||
|
|
||||||
|
### Tests santé (sans dépendances DSM)
|
||||||
|
curl -fsS http://127.0.0.1:17170/ >/dev/null && echo "LLDAP UI OK"
|
||||||
|
curl -fsS http://127.0.0.1:9091/api/health && echo "AUTHELIA LOCAL OK"
|
||||||
|
curl -kfsS https://auth.archicratie.trans-hands.synology.me/api/health && echo "AUTHELIA HTTPS OK"
|
||||||
|
|
||||||
|
### Test TCP LDAP :
|
||||||
|
sudo docker run --rm --network host nicolaka/netshoot:latest sh -lc 'nc -vz -w2 127.0.0.1 3890'
|
||||||
|
|
||||||
|
### Rotate secrets (rotation)
|
||||||
|
|
||||||
|
# Principes :
|
||||||
|
|
||||||
|
Rotation = redémarrage forcé d’Authelia (sessions invalidées)
|
||||||
|
|
||||||
|
Rotation de LLDAP_KEY_SEED est sensible : peut affecter chiffrement des mots de passe.
|
||||||
|
|
||||||
|
# Procédure conseillée :
|
||||||
|
|
||||||
|
Sauvegarder DBs :
|
||||||
|
|
||||||
|
/volume2/docker/auth/data/lldap/users.db
|
||||||
|
|
||||||
|
/volume2/docker/auth/data/authelia/db.sqlite3
|
||||||
|
|
||||||
|
Changer d’abord secrets Authelia (AUTHELIA_SESSION_SECRET, AUTHELIA_STORAGE_ENCRYPTION_KEY)
|
||||||
|
|
||||||
|
docker compose up -d --force-recreate authelia
|
||||||
|
|
||||||
|
Vérifier /api/health + login.
|
||||||
|
|
||||||
|
Reset admin LLDAP (break-glass)
|
||||||
|
|
||||||
|
# Si tu perds le mot de passe admin :
|
||||||
|
|
||||||
|
Activer temporairement LLDAP_FORCE_LDAP_USER_PASS_RESET=true dans l’environnement LLDAP
|
||||||
|
|
||||||
|
Redémarrer LLDAP une seule fois
|
||||||
|
|
||||||
|
Désactiver immédiatement après.
|
||||||
|
|
||||||
|
⚠️ Ne jamais laisser ce flag en permanence : il force le reset à chaque boot.
|
||||||
|
|
||||||
|
## Checklist anti-lockout (indispensable)
|
||||||
|
### 1) Accès direct local (bypass)
|
||||||
|
|
||||||
|
LLDAP UI accessible en local : http://127.0.0.1:17170
|
||||||
|
|
||||||
|
Authelia health local : http://127.0.0.1:9091/api/health
|
||||||
|
|
||||||
|
### 2) Règle Authelia : domaine auth en bypass
|
||||||
|
|
||||||
|
Dans configuration.yml :
|
||||||
|
access_control:
|
||||||
|
rules:
|
||||||
|
- domain: "auth.<domaine>"
|
||||||
|
policy: bypass
|
||||||
|
|
||||||
|
But : pouvoir charger le portail même si les règles des autres domaines cassent.
|
||||||
|
|
||||||
|
### 3) Route de secours reverse-proxy
|
||||||
|
|
||||||
|
Prévoir une route non protégée (ou protégée différemment) pour pouvoir corriger :
|
||||||
|
|
||||||
|
ex: https://admin.<domaine>/ ou un vhost interne LAN-only.
|
||||||
|
|
||||||
|
### 4) Fenêtre privée pour tester
|
||||||
|
|
||||||
|
Toujours tester login/authelia dans un onglet privé pour éviter cookies “fantômes”.
|
||||||
|
|
||||||
|
## Troubleshooting (ce qu’on a rencontré et résolu)
|
||||||
|
### A) YAML/Compose cassé (tabs, doublons)
|
||||||
|
|
||||||
|
# Symptômes :
|
||||||
|
|
||||||
|
mapping key "ports" already defined
|
||||||
|
|
||||||
|
found character that cannot start any token
|
||||||
|
|
||||||
|
# Fix :
|
||||||
|
|
||||||
|
supprimer tabs
|
||||||
|
|
||||||
|
supprimer doublons (volumes/ports/networks)
|
||||||
|
|
||||||
|
valider : docker compose ... config
|
||||||
|
|
||||||
|
### B) Substitution foireuse des variables dans healthcheck
|
||||||
|
|
||||||
|
# Problème :
|
||||||
|
|
||||||
|
$VAR évalué par compose au parse-time
|
||||||
|
|
||||||
|
# Fix :
|
||||||
|
|
||||||
|
utiliser $$VAR dans CMD-SHELL si nécessaire.
|
||||||
|
|
||||||
|
### C) /config monté read-only
|
||||||
|
|
||||||
|
# Symptômes :
|
||||||
|
|
||||||
|
chown: /config/... Read-only file system
|
||||||
|
|
||||||
|
# Fix :
|
||||||
|
|
||||||
|
monter /config en :rw si Authelia doit écrire des backups/keys.
|
||||||
|
|
||||||
|
### D) Timeouts LDAP aléatoires en bridge
|
||||||
|
|
||||||
|
# Symptômes :
|
||||||
|
|
||||||
|
dial tcp <ip>:3890: i/o timeout
|
||||||
|
|
||||||
|
IP Docker “surprise” (subnet 192.168.32.0/20 etc.)
|
||||||
|
|
||||||
|
# Fix robuste DSM :
|
||||||
|
|
||||||
|
passer en network_mode: host + bind 127.0.0.1
|
||||||
|
|
||||||
|
Authelia -> ldap://127.0.0.1:3890
|
||||||
|
|
||||||
|
### E) “Authelia OK mais Gitea redemande login”
|
||||||
|
|
||||||
|
# Normal :
|
||||||
|
|
||||||
|
tant que Gitea n’est pas configuré en OIDC vers Authelia, ce n’est pas du SSO.
|
||||||
|
|
||||||
|
Authelia protège l’accès, mais ne crée pas de session Gitea.
|
||||||
|
|
||||||
67
docs/gitea-pr-main-protege.md
Normal file
67
docs/gitea-pr-main-protege.md
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
# Workflow Git/Gitea — main protégé (PR only)
|
||||||
|
|
||||||
|
## Objectif
|
||||||
|
Éviter toute casse de `main` : on travaille **toujours** via branche + Pull Request.
|
||||||
|
|
||||||
|
## 1) Démarrer propre (local)
|
||||||
|
en bash :
|
||||||
|
|
||||||
|
git fetch origin --prune
|
||||||
|
git checkout main
|
||||||
|
git reset --hard origin/main
|
||||||
|
git clean -fd
|
||||||
|
|
||||||
|
## 2) Créer une branche
|
||||||
|
|
||||||
|
git checkout -b fix/ma-modif
|
||||||
|
|
||||||
|
## 3) Modifier, tester, commit
|
||||||
|
|
||||||
|
npm test
|
||||||
|
git add -A
|
||||||
|
git commit -m "Mon changement"
|
||||||
|
|
||||||
|
## 4) Push (création branche distante)
|
||||||
|
|
||||||
|
git push -u origin fix/ma-modif
|
||||||
|
|
||||||
|
## 5) Créer la Pull Request (UI Gitea)
|
||||||
|
|
||||||
|
Gitea → repository → Pull Requests → New Pull Request
|
||||||
|
|
||||||
|
base : main
|
||||||
|
compare : fix/ma-modif
|
||||||
|
|
||||||
|
Si “je ne vois pas de PR”
|
||||||
|
|
||||||
|
Vérifie d’abord qu’il y a un diff réel :
|
||||||
|
|
||||||
|
git log --oneline origin/main..HEAD
|
||||||
|
|
||||||
|
Si la commande ne sort rien : ta branche ne contient aucun commit différent → PR inutile/invisible.
|
||||||
|
|
||||||
|
## 6) Conflits
|
||||||
|
|
||||||
|
Ne merge pas en local vers main (push refusé si main protégé).
|
||||||
|
On met à jour la branche de PR :
|
||||||
|
|
||||||
|
Option A (simple) : merge main dans la branche
|
||||||
|
|
||||||
|
git fetch origin
|
||||||
|
git merge origin/main
|
||||||
|
# résoudre conflits
|
||||||
|
npm test
|
||||||
|
git push
|
||||||
|
|
||||||
|
Option B (plus propre) : rebase
|
||||||
|
|
||||||
|
git fetch origin
|
||||||
|
git rebase origin/main
|
||||||
|
# résoudre conflits, puis:
|
||||||
|
npm test
|
||||||
|
git push --force-with-lease
|
||||||
|
|
||||||
|
## 7) Merge
|
||||||
|
|
||||||
|
Toujours depuis l’UI de la Pull Request (ou via un mainteneur).
|
||||||
|
|
||||||
69
docs/proposer-whoami-gate.md
Normal file
69
docs/proposer-whoami-gate.md
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
# “Proposer” protégé par groupe (whoami / editors)
|
||||||
|
|
||||||
|
## But
|
||||||
|
Le bouton **Proposer** (création d’issue Gitea pré-remplie) doit être :
|
||||||
|
- visible **uniquement** pour les membres du groupe `editors`,
|
||||||
|
- **absent** pour les autres utilisateurs,
|
||||||
|
- robuste (fail-closed), mais **non-collant** (pas de “bloqué” après un échec transitoire).
|
||||||
|
|
||||||
|
## Pré-requis (build-time)
|
||||||
|
Les variables publiques Astro doivent être injectées au build :
|
||||||
|
- `PUBLIC_GITEA_BASE`
|
||||||
|
- `PUBLIC_GITEA_OWNER`
|
||||||
|
- `PUBLIC_GITEA_REPO`
|
||||||
|
|
||||||
|
Si une seule manque → `giteaReady=false` → Proposer est désactivé.
|
||||||
|
|
||||||
|
### Vérification NAS (slots blue/green)
|
||||||
|
Exemple :
|
||||||
|
- blue : http://127.0.0.1:8081/...
|
||||||
|
- green : http://127.0.0.1:8082/...
|
||||||
|
|
||||||
|
Commande (ex) :
|
||||||
|
`curl -sS http://127.0.0.1:8081/archicratie/archicrat-ia/chapitre-4/ | grep -n "const GITEA_" | head`
|
||||||
|
|
||||||
|
## Signal d’auth (runtime) : `/_auth/whoami`
|
||||||
|
Le site appelle `/_auth/whoami` (same-origin) pour récupérer :
|
||||||
|
- `Remote-User`
|
||||||
|
- `Remote-Groups`
|
||||||
|
Ces headers sont injectés par la chaîne edge (Traefik → Authelia forward-auth).
|
||||||
|
|
||||||
|
### Appel robuste
|
||||||
|
- cache-bust : `?_=${Date.now()}`
|
||||||
|
- `cache: "no-store"`
|
||||||
|
- `credentials: "include"`
|
||||||
|
|
||||||
|
### Critère
|
||||||
|
`groups.includes("editors")`
|
||||||
|
|
||||||
|
## Comportement attendu (UX)
|
||||||
|
- utilisateur editors : le bouton “Proposer” est visible, ouvre la modal, puis ouvre Gitea.
|
||||||
|
- utilisateur non editors : le bouton “Proposer” n’existe pas (retiré du DOM).
|
||||||
|
|
||||||
|
## Pièges connus
|
||||||
|
1) Tester en direct 8081/8082 ne reflète pas toujours la chaîne Traefik+Authelia.
|
||||||
|
2) Un gate “collant” peut rester OFF si l’échec est mis en cache trop agressivement.
|
||||||
|
3) Si “Proposer” est caché via `style.display="none"`, il faut le réafficher via `style.display=""` (pas via `hidden=false`).
|
||||||
|
|
||||||
|
## Debug rapide (console navigateur)
|
||||||
|
en js :
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const r = await fetch("/_auth/whoami?_=" + Date.now(), {
|
||||||
|
credentials: "include",
|
||||||
|
cache: "no-store",
|
||||||
|
redirect: "follow",
|
||||||
|
});
|
||||||
|
const t = await r.text();
|
||||||
|
const groups = (t.match(/^Remote-Groups:\s*(.*)$/mi)?.[1] || "")
|
||||||
|
.split(",").map(s => s.trim()).filter(Boolean);
|
||||||
|
console.log({ ok: r.ok, status: r.status, groups, raw: t.slice(0, 220) + "..." });
|
||||||
|
})();
|
||||||
|
|
||||||
|
## Définition “done”
|
||||||
|
|
||||||
|
Archicratia (editors) voit Proposer et peut ouvrir un ticket.
|
||||||
|
|
||||||
|
s-FunX (non editors) ne voit pas Proposer.
|
||||||
|
|
||||||
|
Les deux slots blue/green injectent les constantes Gitea dans le HTML.
|
||||||
82
docs/runbook-deploiement-web-blue-green.md
Normal file
82
docs/runbook-deploiement-web-blue-green.md
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
# Runbook — Déploiement Archicratie Web Édition (Blue/Green)
|
||||||
|
|
||||||
|
## Arborescence NAS (repère)
|
||||||
|
- `/volume2/docker/archicratie-web/current/` : état courant (Dockerfile, docker-compose.yml, dist buildé en image)
|
||||||
|
- `/volume2/docker/archicratie-web/releases/` : historiques éventuels
|
||||||
|
- `/volume2/docker/edge/` : Traefik + config dynamique
|
||||||
|
|
||||||
|
> Important : les commandes `docker compose -f ...` doivent viser le **docker-compose.yml présent dans `current/`**.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Pré-requis Synology
|
||||||
|
Sur NAS, les commandes ont été exécutées avec :
|
||||||
|
en bash
|
||||||
|
sudo env DOCKER_API_VERSION=1.43 docker ...
|
||||||
|
|
||||||
|
(contexte DSM / compat API)
|
||||||
|
|
||||||
|
### 1) Variables de build (Gitea)
|
||||||
|
|
||||||
|
Dans /volume2/docker/archicratie-web/current créer/maintenir :
|
||||||
|
|
||||||
|
cat > .env <<'EOF'
|
||||||
|
PUBLIC_GITEA_BASE=https://gitea.archicratie.trans-hands.synology.me
|
||||||
|
PUBLIC_GITEA_OWNER=Archicratia
|
||||||
|
PUBLIC_GITEA_REPO=archicratie-edition
|
||||||
|
EOF
|
||||||
|
|
||||||
|
### 2) Build images (blue + green) — méthode robuste
|
||||||
|
|
||||||
|
cd /volume2/docker/archicratie-web/current
|
||||||
|
|
||||||
|
sudo env DOCKER_API_VERSION=1.43 docker compose -f docker-compose.yml build --no-cache web_blue web_green
|
||||||
|
|
||||||
|
Puis recréer les conteneurs sans rebuild :
|
||||||
|
|
||||||
|
sudo env DOCKER_API_VERSION=1.43 docker compose -f docker-compose.yml up -d --force-recreate --no-build web_blue web_green
|
||||||
|
|
||||||
|
### 3) Vérifier que les deux slots sont OK
|
||||||
|
|
||||||
|
curl -sS -D- http://127.0.0.1:8081/ | head -n 12
|
||||||
|
curl -sS -D- http://127.0.0.1:8082/ | head -n 12
|
||||||
|
|
||||||
|
Attendu :
|
||||||
|
|
||||||
|
HTTP/1.1 200 OK
|
||||||
|
|
||||||
|
Server: nginx/...
|
||||||
|
|
||||||
|
### 4) Traefik : s’assurer qu’un seul backend est actif
|
||||||
|
|
||||||
|
Fichier :
|
||||||
|
/volume2/docker/edge/config/dynamic/20-archicratie-backend.yml
|
||||||
|
|
||||||
|
Attendu : une seule URL (8081 OU 8082)
|
||||||
|
|
||||||
|
http:
|
||||||
|
services:
|
||||||
|
archicratie_web:
|
||||||
|
loadBalancer:
|
||||||
|
servers:
|
||||||
|
- url: "http://127.0.0.1:8081"
|
||||||
|
|
||||||
|
### 5) Smoke via Traefik (entrée réelle)
|
||||||
|
|
||||||
|
curl -sS -H 'Host: archicratie.trans-hands.synology.me' http://127.0.0.1:18080/ | head -n 20
|
||||||
|
|
||||||
|
Attendu :
|
||||||
|
|
||||||
|
si non loggé : 302 vers Authelia
|
||||||
|
|
||||||
|
si loggé : HTML du site
|
||||||
|
|
||||||
|
### 6) Piège classique : conflit de nom de conteneur
|
||||||
|
|
||||||
|
Si :
|
||||||
|
Conflict. The container name "/archicratie-web-blue" is already in use...
|
||||||
|
|
||||||
|
Faire :
|
||||||
|
|
||||||
|
sudo docker rm -f archicratie-web-blue
|
||||||
|
sudo env DOCKER_API_VERSION=1.43 docker compose -f docker-compose.yml up -d --force-recreate --no-build web_blue
|
||||||
71
docs/runbook-gitea-branches-pr.md
Normal file
71
docs/runbook-gitea-branches-pr.md
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
# Runbook — Gitea : Branches, PR, Merge (sans se faire piéger)
|
||||||
|
|
||||||
|
## Règle n°1 (hyper importante)
|
||||||
|
Une PR n’apparaît dans Gitea que si la branche contient **au moins 1 commit différent de `main`**.
|
||||||
|
|
||||||
|
Symptôme typique :
|
||||||
|
- `git push -u origin fix/xxx`
|
||||||
|
- et tu vois : `Total 0 ...`
|
||||||
|
→ ça veut dire : **aucun nouveau commit** → la branche est identique à main → pas de vraie PR à proposer.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Workflow “propre” (pas à pas)
|
||||||
|
### 1) Remettre `main` propre
|
||||||
|
en bash
|
||||||
|
|
||||||
|
git checkout main
|
||||||
|
git pull --ff-only
|
||||||
|
|
||||||
|
### 2) Créer une branche de travail
|
||||||
|
|
||||||
|
git checkout -b fix/mon-fix
|
||||||
|
|
||||||
|
### 3) Faire un changement réel
|
||||||
|
|
||||||
|
Modifier le fichier (ex : src/layouts/EditionLayout.astro)
|
||||||
|
|
||||||
|
Vérifier :
|
||||||
|
|
||||||
|
git status -sb
|
||||||
|
|
||||||
|
→ doit montrer un fichier modifié.
|
||||||
|
|
||||||
|
### 4) Tester
|
||||||
|
|
||||||
|
npm test
|
||||||
|
|
||||||
|
### 5) Commit
|
||||||
|
|
||||||
|
git add src/layouts/EditionLayout.astro
|
||||||
|
git commit -m "Fix: ..."
|
||||||
|
|
||||||
|
### 6) Push
|
||||||
|
|
||||||
|
git push -u origin fix/mon-fix
|
||||||
|
|
||||||
|
### 7) Créer la PR dans l’UI Gitea
|
||||||
|
|
||||||
|
# Aller dans Pull Requests
|
||||||
|
|
||||||
|
# New Pull Request
|
||||||
|
|
||||||
|
Base : main
|
||||||
|
|
||||||
|
Compare : fix/mon-fix
|
||||||
|
|
||||||
|
Branch protection (si “Not allowed to push to protected branch main”)
|
||||||
|
|
||||||
|
# C’est normal si main est protégé :
|
||||||
|
|
||||||
|
On ne pousse jamais directement sur main.
|
||||||
|
|
||||||
|
On merge via PR (UI), avec un compte autorisé.
|
||||||
|
|
||||||
|
Si Gitea refuse de merger automatiquement :
|
||||||
|
|
||||||
|
soit tu actives le réglage côté Gitea “manual merge detection” (admin),
|
||||||
|
|
||||||
|
soit tu fais le merge localement MAIS tu ne pourras pas pousser sur main si la protection l’interdit.
|
||||||
|
|
||||||
|
Conclusion : la voie “pro” = PR + merge UI.
|
||||||
67
docs/runbook-proposer-gitea.md
Normal file
67
docs/runbook-proposer-gitea.md
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
# Runbook — Bouton “Proposer” (site → Gitea issue) + Gate Authelia
|
||||||
|
|
||||||
|
## Objectif
|
||||||
|
Permettre une proposition de correction éditoriale depuis un paragraphe du site, en créant une *issue* Gitea pré-remplie, uniquement pour les membres du groupe `editors`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Pré-requis
|
||||||
|
- Traefik (edge) en front
|
||||||
|
- Authelia (forwardAuth) opérationnel
|
||||||
|
- Router `/_auth/whoami` exposé (whoami)
|
||||||
|
- Variables `PUBLIC_GITEA_*` injectées au build du site
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Vérification rapide (navigateur)
|
||||||
|
### 1) Qui suis-je ? (groupes)
|
||||||
|
Dans la console :
|
||||||
|
en js :
|
||||||
|
await fetch("/_auth/whoami?_=" + Date.now(), {
|
||||||
|
credentials: "include",
|
||||||
|
cache: "no-store",
|
||||||
|
}).then(r => r.text());
|
||||||
|
|
||||||
|
Attendu (extraits) :
|
||||||
|
|
||||||
|
Remote-User: <login>
|
||||||
|
|
||||||
|
Remote-Groups: ...,editors,... pour un éditeur
|
||||||
|
|
||||||
|
### 2) Le bouton existe ?
|
||||||
|
document.querySelectorAll(".para-propose").length
|
||||||
|
|
||||||
|
> 0 si editors
|
||||||
|
|
||||||
|
0 si non-editor
|
||||||
|
|
||||||
|
## Vérification côté NAS (build vars)
|
||||||
|
### 1) Blue et Green contiennent les constantes ?
|
||||||
|
|
||||||
|
P="/archicratie/archicrat-ia/chapitre-4/"
|
||||||
|
|
||||||
|
curl -sS "http://127.0.0.1:8081$P" | grep -n "const GITEA_BASE" | head -n 2
|
||||||
|
curl -sS "http://127.0.0.1:8082$P" | grep -n "const GITEA_BASE" | head -n 2
|
||||||
|
|
||||||
|
### 2) Si une des deux est vide → rebuild propre
|
||||||
|
|
||||||
|
Dans /volume2/docker/archicratie-web/current :
|
||||||
|
|
||||||
|
cat > .env <<'EOF'
|
||||||
|
PUBLIC_GITEA_BASE=https://gitea.archicratie.trans-hands.synology.me
|
||||||
|
PUBLIC_GITEA_OWNER=Archicratia
|
||||||
|
PUBLIC_GITEA_REPO=archicratie-edition
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sudo env DOCKER_API_VERSION=1.43 docker compose -f docker-compose.yml build --no-cache web_blue web_green
|
||||||
|
sudo env DOCKER_API_VERSION=1.43 docker compose -f docker-compose.yml up -d --force-recreate --no-build web_blue web_green
|
||||||
|
|
||||||
|
## Dépannage (si Proposer “disparaît”)
|
||||||
|
|
||||||
|
Vérifier groupes via /_auth/whoami
|
||||||
|
|
||||||
|
Vérifier const GITEA_BASE via curl sur le slot actif
|
||||||
|
|
||||||
|
Vérifier que Traefik sert bien le slot actif (grep via curl -H Host: ... http://127.0.0.1:18080/...)
|
||||||
|
|
||||||
|
Ouvrir la console : vérifier qu’aucune erreur JS n’empêche l’injection des outils paragraphe
|
||||||
@@ -379,6 +379,64 @@ const GITEA_REPO = import.meta.env.PUBLIC_GITEA_REPO ?? "";
|
|||||||
const FULL_TEXT_SOFT_LIMIT = 1600;
|
const FULL_TEXT_SOFT_LIMIT = 1600;
|
||||||
const URL_HARD_LIMIT = 6500;
|
const URL_HARD_LIMIT = 6500;
|
||||||
|
|
||||||
|
// ✅ Gate par groupe (Traefik→Authelia→LLDAP via /_auth/whoami)
|
||||||
|
const WHOAMI_PATH = "/_auth/whoami";
|
||||||
|
const PROPOSE_REQUIRED_GROUP = "editors";
|
||||||
|
|
||||||
|
let _authInfoPromise = null;
|
||||||
|
|
||||||
|
function parseWhoamiLine(text, key) {
|
||||||
|
const re = new RegExp(`^${key}:\\s*(.*)$`, "mi");
|
||||||
|
const m = String(text || "").match(re);
|
||||||
|
return (m?.[1] ?? "").trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getAuthInfo() {
|
||||||
|
if (_authInfoPromise) return _authInfoPromise;
|
||||||
|
|
||||||
|
_authInfoPromise = (async () => {
|
||||||
|
const res = await fetch(`${WHOAMI_PATH}?_=${Date.now()}`, {
|
||||||
|
credentials: "include",
|
||||||
|
cache: "no-store",
|
||||||
|
redirect: "follow",
|
||||||
|
});
|
||||||
|
|
||||||
|
const text = await res.text().catch(() => "");
|
||||||
|
|
||||||
|
const groups = parseWhoamiLine(text, "Remote-Groups")
|
||||||
|
.split(",")
|
||||||
|
.map((s) => s.trim())
|
||||||
|
.filter(Boolean);
|
||||||
|
|
||||||
|
return {
|
||||||
|
ok: Boolean(res && res.ok),
|
||||||
|
user: parseWhoamiLine(text, "Remote-User"),
|
||||||
|
name: parseWhoamiLine(text, "Remote-Name"),
|
||||||
|
email: parseWhoamiLine(text, "Remote-Email"),
|
||||||
|
groups,
|
||||||
|
raw: text,
|
||||||
|
};
|
||||||
|
})().catch((err) => {
|
||||||
|
console.warn("[proposer] whoami fetch failed", err);
|
||||||
|
return {
|
||||||
|
ok: false,
|
||||||
|
user: "",
|
||||||
|
name: "",
|
||||||
|
email: "",
|
||||||
|
groups: [],
|
||||||
|
raw: "",
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return _authInfoPromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Promise unique : est-on editor ?
|
||||||
|
// ⚠️ On reste fail-closed, mais NON destructif (on ne supprime pas sur erreur réseau)
|
||||||
|
const isEditorP = giteaReady
|
||||||
|
? getAuthInfo().then((info) => info.groups.includes(PROPOSE_REQUIRED_GROUP))
|
||||||
|
: Promise.resolve(false);
|
||||||
|
|
||||||
const quoteBlock = (s) =>
|
const quoteBlock = (s) =>
|
||||||
String(s || "")
|
String(s || "")
|
||||||
.split(/\r?\n/)
|
.split(/\r?\n/)
|
||||||
@@ -447,6 +505,24 @@ const GITEA_REPO = import.meta.env.PUBLIC_GITEA_REPO ?? "";
|
|||||||
// ==========================
|
// ==========================
|
||||||
const paras = Array.from(document.querySelectorAll('.reading p[id^="p-"]'));
|
const paras = Array.from(document.querySelectorAll('.reading p[id^="p-"]'));
|
||||||
|
|
||||||
|
// Petit helper : fail-closed mais réversible (hide ≠ remove)
|
||||||
|
function hidePropose(el) {
|
||||||
|
try {
|
||||||
|
el.hidden = true;
|
||||||
|
el.style.display = "none";
|
||||||
|
el.setAttribute("aria-hidden", "true");
|
||||||
|
el.setAttribute("tabindex", "-1");
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
function showPropose(el) {
|
||||||
|
try {
|
||||||
|
el.hidden = false;
|
||||||
|
el.style.display = "";
|
||||||
|
el.removeAttribute("aria-hidden");
|
||||||
|
el.removeAttribute("tabindex");
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
for (const p of paras) {
|
for (const p of paras) {
|
||||||
if (p.querySelector(".para-tools")) continue;
|
if (p.querySelector(".para-tools")) continue;
|
||||||
|
|
||||||
@@ -493,12 +569,16 @@ const GITEA_REPO = import.meta.env.PUBLIC_GITEA_REPO ?? "";
|
|||||||
propose.textContent = "Proposer";
|
propose.textContent = "Proposer";
|
||||||
propose.setAttribute("aria-label", "Proposer une correction sur Gitea");
|
propose.setAttribute("aria-label", "Proposer une correction sur Gitea");
|
||||||
|
|
||||||
|
// ✅ fail-closed (mais NON destructif)
|
||||||
|
propose.dataset.requiresGroup = PROPOSE_REQUIRED_GROUP;
|
||||||
|
hidePropose(propose);
|
||||||
|
|
||||||
const raw = (p.textContent || "").trim().replace(/\s+/g, " ");
|
const raw = (p.textContent || "").trim().replace(/\s+/g, " ");
|
||||||
const excerpt = raw.length > 420 ? (raw.slice(0, 420) + "…") : raw;
|
const excerpt = raw.length > 420 ? (raw.slice(0, 420) + "…") : raw;
|
||||||
|
|
||||||
const issueUrl = buildIssueURL(p.id, raw, excerpt);
|
const issueUrl = buildIssueURL(p.id, raw, excerpt);
|
||||||
|
|
||||||
// Lien fallback (si JS casse totalement)
|
// Lien fallback (si JS modal casse totalement)
|
||||||
propose.href = issueUrl;
|
propose.href = issueUrl;
|
||||||
|
|
||||||
// ✅ Marqueurs pour ProposeModal (interception 2 étapes)
|
// ✅ Marqueurs pour ProposeModal (interception 2 étapes)
|
||||||
@@ -506,9 +586,6 @@ const GITEA_REPO = import.meta.env.PUBLIC_GITEA_REPO ?? "";
|
|||||||
propose.dataset.url = issueUrl;
|
propose.dataset.url = issueUrl;
|
||||||
propose.dataset.full = raw;
|
propose.dataset.full = raw;
|
||||||
|
|
||||||
// ❌ PAS de target=_blank ici
|
|
||||||
// ❌ PAS de rel noopener ici
|
|
||||||
|
|
||||||
row.appendChild(propose);
|
row.appendChild(propose);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,6 +621,22 @@ const GITEA_REPO = import.meta.env.PUBLIC_GITEA_REPO ?? "";
|
|||||||
p.appendChild(tools);
|
p.appendChild(tools);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ✅ Après insertion : on autorise Proposer seulement si groupe editors
|
||||||
|
// - ok=false => remove (pas d’UI “Proposer” pour les non-éditeurs)
|
||||||
|
// - erreur fetch => on garde HIDDEN (non destructif) ; un reload pourra réussir
|
||||||
|
if (giteaReady) {
|
||||||
|
isEditorP.then((ok) => {
|
||||||
|
const els = document.querySelectorAll(".para-propose");
|
||||||
|
for (const el of els) {
|
||||||
|
if (ok) showPropose(el);
|
||||||
|
else el.remove();
|
||||||
|
}
|
||||||
|
}).catch((err) => {
|
||||||
|
console.warn("[proposer] gate failed; keeping Proposer hidden", err);
|
||||||
|
document.querySelectorAll(".para-propose").forEach((el) => hidePropose(el));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Auto-checkpoint
|
// Auto-checkpoint
|
||||||
let lastAuto = 0;
|
let lastAuto = 0;
|
||||||
function writeLastSeen(id) {
|
function writeLastSeen(id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user