33800 Docs

← Retour

Proposition: Systeme de Profils VPN WireGuard

Date: 27/01/2026 17:22 Priorite: HAUTE Effort estime: M (quelques heures) Status: EN ATTENTE VALIDATION


Objectif

Creer un systeme de profils VPN WireGuard reutilisables, separés des instances SSH, et permettre d'associer un profil a une instance SSH lors de sa creation/modification.

Probleme actuel


Architecture proposee

┌─────────────────────────────────────────────────────────────────────┐
│                         PROFILS VPN                                  │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐                  │
│  │   Rhinov    │  │   86000     │  │   Home      │                  │
│  │ (Entreprise)│  │   (Raph)    │  │   (Perso)   │                  │
│  └──────┬──────┘  └──────┬──────┘  └──────┬──────┘                  │
│         │                │                │                          │
└─────────┼────────────────┼────────────────┼──────────────────────────┘
          │                │                │
          ▼                ▼                ▼
┌─────────────────────────────────────────────────────────────────────┐
│                      INSTANCES SSH                                   │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐                  │
│  │ rhinov-srv1 │  │ raph-nas    │  │ home-rpi    │                  │
│  │ VPN: Rhinov │  │ VPN: 86000  │  │ VPN: Home   │                  │
│  └─────────────┘  └─────────────┘  └─────────────┘                  │
└─────────────────────────────────────────────────────────────────────┘

Implementation

Phase 1: Backend - Table vpn_profiles

Nouvelle table Supabase : connectors.vpn_profiles

CREATE TABLE connectors.vpn_profiles (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id UUID NOT NULL REFERENCES auth.users(id),
  name VARCHAR(100) NOT NULL,
  description TEXT,
  -- WireGuard config
  private_key_encrypted TEXT NOT NULL,
  public_key TEXT NOT NULL,
  address TEXT NOT NULL,           -- ex: "10.9.0.9/32"
  -- Peer config
  endpoint TEXT NOT NULL,          -- ex: "92.154.124.233:11220"
  peer_public_key TEXT NOT NULL,
  preshared_key_encrypted TEXT,    -- optionnel
  allowed_ips TEXT NOT NULL,       -- ex: "0.0.0.0/0, ::/0"
  dns TEXT,                        -- ex: "192.168.10.250, 192.168.10.100"
  persistent_keepalive INT DEFAULT 25,
  -- Metadata
  created_at TIMESTAMPTZ DEFAULT NOW(),
  updated_at TIMESTAMPTZ DEFAULT NOW(),
  UNIQUE(user_id, name)
);

Phase 2: Backend - Service vpn-profiles.ts

Nouveau fichier : src/services/vpn-profiles.ts

Fonction Description
create(userId, config) Creer un profil VPN
update(profileId, userId, config) Modifier un profil
delete(profileId, userId) Supprimer un profil
list(userId) Lister les profils de l'utilisateur
get(profileId, userId) Obtenir un profil
importFromConfig(userId, name, wgConfig) Importer depuis fichier .conf

Phase 3: Backend - Endpoints API

Endpoint Methode Description
/api/vpn/profiles GET Lister mes profils VPN
/api/vpn/profiles POST Creer un profil
/api/vpn/profiles/:id GET Obtenir un profil
/api/vpn/profiles/:id PUT Modifier un profil
/api/vpn/profiles/:id DELETE Supprimer un profil
/api/vpn/profiles/import POST Importer depuis .conf

Phase 4: Backend - Modification instances SSH

Modifier user_connectors.token_metadata pour SSH :

interface SSHTokenMetadata {
  host: string;
  port: number;
  username: string;
  // ... autres champs existants
  vpn_profile_id?: string;  // NOUVEAU: reference au profil VPN
}

Modifier le service wireguard.ts :

Phase 5: Frontend - Page Profils VPN

Nouvelle page : /vpn/profiles

Formulaire creation/modification :

Phase 6: Frontend - Modification formulaire SSH

Page : Creation/Modification instance SSH

Ajouter un champ select :

VPN WireGuard: [Aucun ▼]
              - Aucun
              - Rhinov
              - 86000 (Raph)
              + Creer un nouveau profil

Phase 7: Frontend - Instance SSH avec VPN

Page info instance SSH :

Si un profil VPN est associe :


Fichiers a modifier/creer

Backend (connectors-api)

Fichier Action
src/services/vpn-profiles.ts CREER
src/services/wireguard.ts MODIFIER (utiliser profil)
src/index.ts MODIFIER (ajouter endpoints)

Frontend (connectors-front)

Fichier Action
src/routes/vpn/profiles/index.tsx CREER (liste)
src/routes/vpn/profiles/new.tsx CREER (creation)
src/routes/vpn/profiles/[id]/index.tsx CREER (detail/edit)
src/components/VpnProfileForm.tsx CREER
src/components/VpnProfileSelect.tsx CREER (dropdown)
src/routes/connectors/ssh/new.tsx MODIFIER (ajouter select VPN)
src/routes/connectors/instance/[id]/index.tsx MODIFIER (afficher VPN)
src/components/VpnConfig.tsx SUPPRIMER ou ADAPTER

Base de donnees

Action Description
Migration SQL Creer table connectors.vpn_profiles

Migration des configs existantes

Si des instances SSH ont deja une config VPN dans token_metadata.vpn_config :

  1. Creer un profil VPN automatiquement avec le nom de l'instance
  2. Lier l'instance au nouveau profil
  3. Supprimer l'ancienne config inline

Avantages

  1. Reutilisabilite : Un profil "Rhinov" pour toutes les instances Rhinov
  2. UX claire : Config VPN dans un endroit dedie, pas melangee avec SSH
  3. Import facile : Coller sa config .conf directement
  4. Gestion centralisee : Modifier un profil = toutes les instances mises a jour

Plan d'execution

Etape Description Temps estime
1 Migration SQL + table vpn_profiles 10 min
2 Service vpn-profiles.ts 30 min
3 Endpoints API 20 min
4 Modifier wireguard.ts 15 min
5 Pages frontend profils VPN 45 min
6 Composant VpnProfileSelect 15 min
7 Modifier formulaire SSH 15 min
8 Modifier page instance 15 min
9 Tests 15 min
Total ~3h

Questions pour validation

  1. Import .conf : Tu veux pouvoir coller le contenu d'un fichier .conf et qu'il soit parse automatiquement ?

  2. Navigation : Ou mettre le lien vers les profils VPN ?

    • Option A : Menu principal "VPN Profiles"
    • Option B : Sous-menu de "Connecteurs"
    • Option C : Page Settings
  3. Migration : Migrer automatiquement les configs VPN existantes vers des profils ?


Validation