iri-shield 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# iri-shield
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/iri-shield)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[](https://nodejs.org)
|
|
6
|
-
[](#-explainable-risk-scoring)
|
|
7
7
|
[](#-privacy-by-design)
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
> **
|
|
14
|
+
> **Open-source API security middleware for Express.js** featuring **Explainable Risk Scoring**, **Multi-Signal Identity Continuity Analysis**, **Behavioural Anomaly Detection**, **Attack Sequence Correlation**, **Configurable Rule Engine**, **Automated PII/Secret Redaction**, and an **Interactive Real-Time Admin Dashboard**.
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
@@ -34,6 +34,11 @@
|
|
|
34
34
|
- [Comprehensive Research Evaluation Summary (v1.2.0-research)](#comprehensive-research-evaluation-summary-v120-research)
|
|
35
35
|
- [Multi-Workload Performance \& Latency Matrix](#multi-workload-performance--latency-matrix)
|
|
36
36
|
- [Interactive Admin Dashboard](#interactive-admin-dashboard)
|
|
37
|
+
- [🚀 Real-World \& Production Deployment Guide](#-real-world--production-deployment-guide)
|
|
38
|
+
- [1. Disabling Testing Mode for Real Traffic](#1-disabling-testing-mode-for-real-traffic)
|
|
39
|
+
- [2. Reverse Proxy \& Real Client IP (`trustProxy`)](#2-reverse-proxy--real-client-ip-trustproxy)
|
|
40
|
+
- [3. Securing Admin Dashboard Credentials](#3-securing-admin-dashboard-credentials)
|
|
41
|
+
- [4. Production Ready Configuration Example](#4-production-ready-configuration-example)
|
|
37
42
|
- [Full Configuration Reference](#full-configuration-reference)
|
|
38
43
|
- [Security \& Auth Utilities](#security--auth-utilities)
|
|
39
44
|
- [Academic \& Research Defense](#academic--research-defense)
|
|
@@ -321,15 +326,117 @@ Access the real-time security dashboard at `/iri-shield`:
|
|
|
321
326
|
|
|
322
327
|
---
|
|
323
328
|
|
|
329
|
+
## 🚀 Real-World & Production Deployment Guide
|
|
330
|
+
|
|
331
|
+
`iri-shield` is built to protect production Express.js APIs against real-world threats. When moving from local testing or dataset benchmarks to production, follow these steps:
|
|
332
|
+
|
|
333
|
+
### 1. Disabling Testing Mode for Real Traffic
|
|
334
|
+
By default in `iri-shield`, **testing mode is already disabled** (`enabled: false`). However, if you enabled it during local simulation or integration testing, ensure it is set to `false` or removed in production.
|
|
335
|
+
|
|
336
|
+
> [!WARNING]
|
|
337
|
+
> When `testing.enabled: true`, clients can spoof their IP, User-Agent, and Session ID via custom headers (`x-iri-test-ip`, `x-iri-test-user-agent`, etc.) for benchmark replay. **Never enable testing mode in production environments!**
|
|
338
|
+
|
|
339
|
+
```js
|
|
340
|
+
const shield = createShield({
|
|
341
|
+
appName: 'my-production-api',
|
|
342
|
+
// Ensure testing mode is off (or simply omit the testing property)
|
|
343
|
+
testing: {
|
|
344
|
+
enabled: false,
|
|
345
|
+
allowClientOverrides: false
|
|
346
|
+
},
|
|
347
|
+
// ...
|
|
348
|
+
});
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### 2. Reverse Proxy & Real Client IP (`trustProxy`)
|
|
352
|
+
If your application runs behind a reverse proxy, load balancer, or CDN (such as **Nginx**, **Cloudflare**, **AWS ALB**, or **Heroku**):
|
|
353
|
+
- Set `trustProxy: true` (or express `app.set('trust-proxy', 1)`) so `iri-shield` reads real client IPs from `CF-Connecting-IP`, `X-Forwarded-For`, or `X-Real-IP`.
|
|
354
|
+
|
|
355
|
+
```js
|
|
356
|
+
const app = express();
|
|
357
|
+
app.set('trust proxy', true);
|
|
358
|
+
|
|
359
|
+
const shield = createShield({
|
|
360
|
+
appName: 'my-production-api',
|
|
361
|
+
trustProxy: true,
|
|
362
|
+
// ...
|
|
363
|
+
});
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### 3. Securing Admin Dashboard Credentials
|
|
367
|
+
Never hardcode default credentials in production code. Load admin username and password from environment variables:
|
|
368
|
+
|
|
369
|
+
```js
|
|
370
|
+
dashboard: {
|
|
371
|
+
enabled: true,
|
|
372
|
+
path: '/iri-shield',
|
|
373
|
+
username: process.env.SHIELD_ADMIN_USER || 'admin',
|
|
374
|
+
password: process.env.SHIELD_ADMIN_PASSWORD, // enforce strong secret via .env
|
|
375
|
+
refreshMs: 60 * 1000
|
|
376
|
+
}
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### 4. Production Ready Configuration Example
|
|
380
|
+
|
|
381
|
+
```js
|
|
382
|
+
const express = require('express');
|
|
383
|
+
const { createShield } = require('iri-shield');
|
|
384
|
+
|
|
385
|
+
const app = express();
|
|
386
|
+
const isProd = process.env.NODE_ENV === 'production';
|
|
387
|
+
|
|
388
|
+
if (isProd) {
|
|
389
|
+
app.set('trust proxy', true);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const shield = createShield({
|
|
393
|
+
appName: process.env.APP_NAME || 'my-api',
|
|
394
|
+
security: isProd ? 'high' : 'medium', // 'low' | 'medium' | 'high'
|
|
395
|
+
trustProxy: isProd,
|
|
396
|
+
failureMode: 'fail-open', // resilient: won't bring down app on errors
|
|
397
|
+
|
|
398
|
+
// Testing mode — automatically OFF in production
|
|
399
|
+
testing: {
|
|
400
|
+
enabled: !isProd,
|
|
401
|
+
allowClientOverrides: !isProd
|
|
402
|
+
},
|
|
403
|
+
|
|
404
|
+
// Persistent storage for production blocks and analytics
|
|
405
|
+
storage: {
|
|
406
|
+
mode: process.env.STORAGE_MODE || 'sqlite', // 'sqlite' or 'mongodb'
|
|
407
|
+
sqliteFile: process.env.SQLITE_PATH || './data/iri-shield.sqlite'
|
|
408
|
+
},
|
|
409
|
+
|
|
410
|
+
// Secure Dashboard
|
|
411
|
+
dashboard: {
|
|
412
|
+
enabled: true,
|
|
413
|
+
path: '/iri-shield',
|
|
414
|
+
username: process.env.SHIELD_ADMIN_USER || 'admin',
|
|
415
|
+
password: process.env.SHIELD_ADMIN_PASSWORD || 'ChangeThisSecret123!'
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
app.use(shield.middleware);
|
|
420
|
+
app.use('/iri-shield', shield.dashboard);
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
324
425
|
## Full Configuration Reference
|
|
325
426
|
|
|
326
427
|
```js
|
|
327
428
|
const shield = createShield({
|
|
328
429
|
appName: 'iri-shield',
|
|
329
430
|
security: 'medium', // 'low' | 'medium' | 'high'
|
|
330
|
-
trustProxy: false,
|
|
431
|
+
trustProxy: false, // Set true if behind Cloudflare, Nginx, or AWS ALB
|
|
331
432
|
failureMode: 'fail-open', // 'fail-open' | 'fail-closed'
|
|
332
433
|
|
|
434
|
+
// Testing Mode (False by default — enables header/body overrides for testing)
|
|
435
|
+
testing: {
|
|
436
|
+
enabled: false, // Keep FALSE in production
|
|
437
|
+
allowClientOverrides: false
|
|
438
|
+
},
|
|
439
|
+
|
|
333
440
|
// HTTP Security Headers & CORS
|
|
334
441
|
helmet: {
|
|
335
442
|
enabled: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iri-shield",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Enterprise Express.js security middleware — explainable risk scoring, multi-signal identity profiling, behavioural anomaly detection, attack correlation, sensitive-data redaction, and dashboard monitoring.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"iri-shield",
|