feat: временный публичный /exp без авторизации (v0.4.9)

This commit is contained in:
2026-05-31 09:03:30 +03:00
parent 02d842fd73
commit ea4551ce13
2 changed files with 20 additions and 1 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "ipwhitelist",
"version": "0.4.8",
"version": "0.4.9",
"description": "IP WhiteList microservice for cloud provider",
"main": "server.js",
"scripts": {
+19
View File
@@ -76,6 +76,25 @@ async function start() {
// JWKS endpoint для валидации токенов внешними сервисами (только в mock-режиме)
if (auth.jwksHandler) app.get('/.well-known/jwks.json', auth.jwksHandler);
// ── ВРЕМЕННЫЙ публичный endpoint /exp (без авторизации) ──────────────────
// TODO: убрать когда /export станет публичным по ТЗ п. 4.7
{
const { exportLimiter } = require('./src/middleware/rateLimit');
const { aggregateCIDRs } = require('./src/validators');
app.get('/exp', exportLimiter, async (req, res) => {
try {
const cidrs = await q.getExportCIDRs(null); // null = все компании
const aggregated = aggregateCIDRs(cidrs);
res.setHeader('Content-Type', 'text/plain; charset=utf-8');
res.setHeader('Content-Disposition', 'inline; filename="whitelist.txt"');
res.send(aggregated.join('\n') + (aggregated.length ? '\n' : ''));
} catch (e) {
console.error('/exp error:', e);
res.status(500).send('Export error');
}
});
}
// ── REST API v1 (Bearer JWT, без сессий/CSRF) ─────────────────────────────
const { createApiRouter } = require('./src/api/index');
app.use('/api/v1', createApiRouter({ auth, q }));