feat: ajout du paramètre VAULT_CONFS_DIR pour configurer le dossier de destination

- Ajout du paramètre VAULT_CONFS_DIR dans le SDK pour personnaliser le dossier de destination
- Modification de syncLocalFiles() pour utiliser VAULT_CONFS_DIR par défaut
- Création du fichier .env.example avec tous les paramètres disponibles
- Mise à jour de la documentation SDK avec tableau des variables d\environnement
This commit is contained in:
4NK Dev 2025-10-01 11:44:23 +00:00
parent 4d314db889
commit e525d0b29c
14 changed files with 30 additions and 13 deletions

View File

@ -31,8 +31,19 @@ Le SDK peut être configuré automatiquement via un fichier `.env` :
VAULT_USER=demo_user_001
VAULT_KEY=JYyybYFXe9hghRI9d1mpoQ1uYYxpt/6lzYPOWrxruG0=
VAULT_ENV=dev
VAULT_CONFS_DIR=../confs # Dossier de destination pour les fichiers synchronisés
```
#### Variables d'environnement disponibles
| Variable | Description | Requis | Défaut |
|----------|-------------|--------|--------|
| `VAULT_USER` | Identifiant utilisateur pour l'authentification | ✅ | - |
| `VAULT_KEY` | Clé de déchiffrement (gérée automatiquement) | ✅ | - |
| `VAULT_ENV` | Environnement par défaut | ✅ | - |
| `VAULT_CONFS_DIR` | Dossier de destination pour les fichiers synchronisés | ❌ | `../confs` |
| `VAULT_URL` | URL de l'API Vault | ❌ | `https://vault.4nkweb.com:6666` |
### Configuration manuelle
```typescript
@ -125,9 +136,10 @@ const routes = await client.getRoutes();
console.log(`Routes disponibles: ${routes.total_routes}`);
// Synchronisation des fichiers déchiffrés localement avec variables résolues
// Le dossier de destination peut être configuré via VAULT_CONFS_DIR dans .env
const syncResult = await client.syncLocalFiles({
environment: 'dev',
localDir: '../confs',
localDir: '../confs', // Optionnel: utilise VAULT_CONFS_DIR par défaut
verbose: true
});

View File

@ -369,9 +369,12 @@ export class SecureVaultClient {
* Les fichiers existants dans confs/ sont toujours écrasés pour avoir le contenu le plus récent
*/
async syncLocalFiles(options: SyncOptions): Promise<SyncResult> {
// Récupérer le dossier de destination depuis les variables d'environnement
const defaultConfsDir = process.env['VAULT_CONFS_DIR'] || '../confs';
const {
environment,
localDir = '../confs',
localDir = defaultConfsDir,
verbose = false
} = options;

View File

@ -0,0 +1 @@
./

View File

@ -1,5 +1,5 @@
location $URL_ROUTE_BLINDBIT/ {
proxy_pass http://localhost:$BLINDBIT_PORT/;
proxy_pass http://127.0.0.1:$BLINDBIT_PORT/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

View File

@ -1,5 +1,5 @@
location $URL_ROUTE_GRAFAN/ {
proxy_pass http://localhost:$GRAFANA_PORT/;
proxy_pass http://127.0.0.1:$GRAFANA_PORT/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

View File

@ -1,5 +1,5 @@
location $URL_ROUTE_IHM_CLIENT {
proxy_pass http://localhost:$IHM_CLIENT_PORT;
proxy_pass http://127.0.0.1:$IHM_CLIENT_PORT;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

View File

@ -6,7 +6,7 @@
proxy_hide_header ETag;
proxy_hide_header Last-Modified;
rewrite ^$URL_ROUTE_LECOFFRE_FRONT/(.*)$ /$1 break;
proxy_pass http://localhost:$LECOFFRE_FRONT_PORT;
proxy_pass http://127.0.0.1:$LECOFFRE_FRONT_PORT;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@ -14,7 +14,7 @@
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Request-ID $x_request_id;
proxy_set_header X-Session-ID $http_x_session_id;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;

View File

@ -7,5 +7,5 @@
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
rewrite ^$URL_ROUTE_LECOFFRE_FRONT_HMR/(.*)$ $URL_ROUTE_LECOFFRE_FRONT/$1 break;
proxy_pass http://localhost:$LECOFFRE_FRONT_PORT;
proxy_pass http://127.0.0.1:$LECOFFRE_FRONT_PORT;
}

View File

@ -1,5 +1,5 @@
location /loki/ {
proxy_pass http://localhost:$LOKI_PORT/;
proxy_pass http://127.0.0.1:$LOKI_PORT/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

View File

@ -1,5 +1,5 @@
location ^~ $URL_ROUTE_NEXT/ {
proxy_pass http://localhost:$LECOFFRE_FRONT_PORT$URL_ROUTE_NEXT/;
proxy_pass http://127.0.0.1:$LECOFFRE_FRONT_PORT$URL_ROUTE_NEXT/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

View File

@ -1,5 +1,5 @@
location $URL_ROUTE_STATUS_API/ {
proxy_pass http://localhost:$STATUS_API_PORT;
proxy_pass http://127.0.0.1:$STATUS_API_PORT;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

View File

@ -1,5 +1,5 @@
location $URL_ROUTE_STATUS {
proxy_pass http://localhost:3006/api;
proxy_pass http://127.0.0.1:3006/api;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

View File

@ -1,5 +1,5 @@
location /ws/ {
proxy_pass http://localhost:$SIGNER_PORT/;
proxy_pass http://127.0.0.1:$SIGNER_PORT/;
proxy_set_header Sec-WebSocket-Key $http_sec_websocket_key;
proxy_set_header Sec-WebSocket-Version $http_sec_websocket_version;
proxy_set_header Sec-WebSocket-Protocol $http_sec_websocket_protocol;

View File

@ -0,0 +1 @@
./