chore: initial deploy bundle
This commit is contained in:
@@ -28,7 +28,7 @@ export let env = {
|
||||
secretPath: p.VAULT_SECRET_PATH || 'database',
|
||||
jwtKidPath: p.VAULT_JWT_KID_PATH || 'jwt/kid',
|
||||
jwtKidsPrefix: p.VAULT_JWT_KIDS_PREFIX || 'jwt/kids',
|
||||
csrfPath: p.VAULT_CSRF_PATH || 'csrf',
|
||||
csrfPath: p.VAULT_CSRF_PATH || '',
|
||||
},
|
||||
cors: {
|
||||
origins: (p.CORS_ORIGINS || 'http://localhost:3000').split(','),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Request, Response, NextFunction } from 'express';
|
||||
import { verifyCsrfToken, isCsrfConfigured } from '../services/csrf.service';
|
||||
import { env } from '../config/env';
|
||||
import { logger } from '../lib/logger';
|
||||
|
||||
const SAFE_METHODS = new Set(['GET', 'HEAD', 'OPTIONS']);
|
||||
@@ -10,8 +11,13 @@ export function csrfMiddleware(req: Request, res: Response, next: NextFunction):
|
||||
return;
|
||||
}
|
||||
|
||||
// If CSRF is not configured (Vault down при старте) — пропускаем, чтобы не блокировать сервис.
|
||||
// В логах будет warning — легко заметить.
|
||||
// CSRF отключён если VAULT_CSRF_PATH не задан
|
||||
if (!env.vault.csrfPath) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
// Секрет не загрузился (Vault недоступен) — пропускаем чтобы не блокировать сервис
|
||||
if (!isCsrfConfigured()) {
|
||||
logger.warn('CSRF check skipped: secret not loaded');
|
||||
next();
|
||||
|
||||
@@ -40,10 +40,12 @@ export async function refreshAllKeys(): Promise<void> {
|
||||
logger.error(`Failed to refresh JWT keys: ${err.message}`);
|
||||
}
|
||||
|
||||
try {
|
||||
await loadCsrfSecret(addr, token, mount, csrfPath);
|
||||
} catch (err: any) {
|
||||
logger.error(`Failed to refresh CSRF secret: ${err.message}`);
|
||||
if (csrfPath) {
|
||||
try {
|
||||
await loadCsrfSecret(addr, token, mount, csrfPath);
|
||||
} catch (err: any) {
|
||||
logger.error(`Failed to refresh CSRF secret: ${err.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user