From 91366212d482f2b39532c18f701448affc45897e Mon Sep 17 00:00:00 2001 From: Bruno Charest Date: Wed, 3 Jun 2026 09:42:08 -0400 Subject: [PATCH] Help: dedicated webhooks section with examples, event table, API details --- frontend/index.html | 139 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 129 insertions(+), 10 deletions(-) diff --git a/frontend/index.html b/frontend/index.html index aca2705..20a4c7d 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -798,6 +798,7 @@
  • ⌨️ Palette
  • ⌨️ Raccourcis
  • 🔗 Partage
  • +
  • 🪝 Webhooks
  • 💾 Sauvegardes
  • 🛡️ Sécurité
  • 🎨 Personnalisation
  • @@ -1319,18 +1320,136 @@
  • Gestion des liens : Liste et révocation dans les Configurations
  • Export PDF : Téléchargement du document partagé en PDF via /s/{token}/pdf
  • - -

    Webhooks

    -

    Les webhooks notifient des services externes lors des changements de fichiers.

    - - + +
    +

    🪝 Webhooks

    +

    Les webhooks permettent à ObsiGate de notifier automatiquement des services externes lorsque des fichiers ou dossiers sont modifiés. Chaque événement déclenche un POST HTTP vers l'URL de votre choix, avec un payload JSON détaillé.

    + +

    Cas d'usage

    + + +

    Événements supportés

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ÉvénementDéclencheurDonnées
    file_createdCréation via l'API ou la palettevault, path
    file_deletedSuppression via l'API ou l'éditeurvault, path
    file_renamedRenommage via l'APIvault, old_path, new_path
    directory_createdCréation de dossier via l'APIvault, path
    directory_deletedSuppression de dossier via l'APIvault, path
    directory_renamedRenommage de dossier via l'APIvault, old_path, new_path
    +
    +

    Note : l'événement file_modified est réservé pour usage futur. Les modifications de contenu via l'éditeur ne déclenchent pas encore de webhook.

    + +

    Format du payload

    +

    Chaque webhook reçoit un POST avec Content-Type: application/json :

    +
    {
    +  "event": "file_created",
    +  "timestamp": "2026-06-03T14:30:00.123456+00:00",
    +  "data": {
    +    "vault": "IT",
    +    "path": "procedures/deploiement.md"
    +  }
    +}
    + +

    Sécurité : signature HMAC-SHA256

    +

    Si vous configurez un secret, chaque requête inclut un header X-ObsiGate-Signature :

    +
    X-ObsiGate-Signature: sha256=9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
    +

    Pour vérifier côté récepteur : calculez HMAC-SHA256(corps_brut, secret) et comparez. Le header X-ObsiGate-Event contient aussi le type d'événement pour un routage rapide.

    + +

    Configuration

    +

    Les webhooks se gèrent dans le modal Configurations (⚙️ menu Options), section Webhooks. Réservé aux administrateurs.

    +
      +
    1. Allez dans ⚙️ Configurations → onglet Webhooks
    2. +
    3. Remplissez : Nom (descriptif), URL (endpoint cible), Secret (optionnel)
    4. +
    5. Cochez les événements à écouter
    6. +
    7. Cliquez Ajouter
    8. +
    +

    Les webhooks peuvent être activés/désactivés, modifiés ou supprimés à tout moment. Le last_fired_at indique la dernière exécution.

    + +

    Exemples concrets

    + +

    Récepteur Python (Flask)

    +
    from flask import Flask, request\nimport hmac, hashlib\n\napp = Flask(__name__)\nWEBHOOK_SECRET = "mon-secret"  # même que dans ObsiGate\n\n@app.route("/webhook", methods=["POST"])\ndef webhook():\n    # Vérifier la signature\n    signature = request.headers.get("X-ObsiGate-Signature", "")\n    body = request.get_data()\n    expected = "sha256=" + hmac.new(\n        WEBHOOK_SECRET.encode(), body, hashlib.sha256\n    ).hexdigest()\n    if not hmac.compare_digest(signature, expected):\n        return "Invalid signature", 403\n\n    payload = request.get_json()\n    print(f"Événement: {payload['event']}")\n    print(f"Fichier: {payload['data']['vault']}/{payload['data']['path']}")\n    return "OK", 200\n\napp.run(port=5000)
    + +

    n8n / Make (no-code)

    +
      +
    1. Créez un Webhook Trigger dans n8n ou Make
    2. +
    3. Copiez l'URL générée (ex: https://n8n.monserveur.com/webhook/abc123)
    4. +
    5. Dans ObsiGate, ajoutez un webhook pointant vers cette URL
    6. +
    7. Sélectionnez les événements souhaités
    8. +
    9. Le workflow se déclenche automatiquement à chaque événement
    10. +
    + +

    Notification Discord

    +

    Utilisez un webhook relais (n8n, Make, ou un script) pour transformer le payload ObsiGate en message Discord :

    +
    # Exemple avec curl + jq dans un script bash
    +WEBHOOK_URL="https://discord.com/api/webhooks/..."
    +OBSIGATE_SECRET="mon-secret"
    +
    +# Lire le payload depuis stdin
    +read -r payload
    +event=$(echo "$payload" | jq -r '.event')
    +path=$(echo "$payload" | jq -r '.data.path')
    +
    +curl -H "Content-Type: application/json" -d "{
    +  \"content\": \"📝 **$event** — $path\"
    +}" "$WEBHOOK_URL"
    + +

    Tester avec curl

    +
    # Simuler ce qu'ObsiGate envoie (pour tester votre endpoint)
    +curl -X POST https://votre-serveur.com/webhook \
    +  -H "Content-Type: application/json" \
    +  -H "X-ObsiGate-Event: file_created" \
    +  -H "X-ObsiGate-Signature: sha256=$(echo -n '{"event":"file_created",...}' | openssl dgst -sha256 -hmac 'mon-secret' | cut -d' ' -f2)" \
    +  -d '{"event":"file_created","timestamp":"2026-06-03T14:30:00Z","data":{"vault":"IT","path":"notes/test.md"}}'
    + +

    Limitations actuelles

    + +

    💾 Sauvegardes et Audits