Skip to content

Commit d0f9c44

Browse files
Merge pull request #154 from PerimeterX/release/v7.6.0
Release version 7.6.0 to master
2 parents eba957f + e74ec32 commit d0f9c44

File tree

5 files changed

+125
-38
lines changed

5 files changed

+125
-38
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## [7.6.0] - 2023-01-26
9+
10+
### Added
11+
12+
- Support for CORS preflight requests and CORS headers in block responses
13+
814
## [7.5.0] - 2023-01-26
915

1016
### Added

README.md

Lines changed: 114 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# [PerimeterX](http://www.perimeterx.com) Express.js Middleware
77

8-
> Latest stable version: [v7.5.0](https://www.npmjs.com/package/perimeterx-node-express)
8+
> Latest stable version: [v7.6.0](https://www.npmjs.com/package/perimeterx-node-express)
99
1010
## Table of Contents
1111

@@ -14,38 +14,39 @@
1414
- [Configuration](#configuration)
1515
- [Required Configuration](#requiredConfiguration)
1616
- [Optional Configuration](#optionalConfiguration)
17-
- [Module Enabled](#moduleEnabled)
18-
- [Module Mode](#moduleMode)
19-
- [Blocking Score](#blockingScore)
20-
- [Send Page Activities](#sendPageActivities)
21-
- [Send Block Activities](#sendBlockActivities)
22-
- [Logger Severity](#loggerSeverity)
23-
- [Sensitive Routes](#sensitiveRoutes)
24-
- [Enforced Specific Routes](#enforcedSpecificRoutes)
25-
- [Monitored Specific Routes](#monitoredSpecificRoutes)
26-
- [Filter By Route](#filterByRoute)
27-
- [Sensitive Headers](#sensitiveHeaders)
28-
- [IP Headers](#ipHeaders)
29-
- [First Party Enabled](#firstPartyEnabled)
30-
- [CD First Party Enabled](#CDFirstPartyEnabled)
31-
- [Custom Request Handler](#customRequestHandler)
32-
- [Additional Activity Handler](#additionalActivityHandler)
33-
- [Enrich Custom Parameters](#enrichCustomParams)
34-
- [CSS Ref](#cssRef)
35-
- [JS Ref](#jsRef)
36-
- [Custom Logo](#customLogo)
37-
- [Secured PXHD cookie](#securedpxhd)
38-
- [Proxy Support](#proxySupport)
39-
- [Custom Cookie Header](#customCookieHeader)
40-
- [Filter Traffic by User Agent](#filterByUserAgent)
41-
- [Filter Traffic by IP](#filterByIP)
42-
- [Filter Traffic by HTTP Method](#filterByMethod)
43-
- [Test Block Flow on Monitoring Mode](#bypassMonitorHeader)
44-
- [CSP Enabled](#cspEnabled)
45-
- [CSP Policy Refresh Interval](#cspPolicyRefreshIntervalMinutes)
46-
- [CSP Invalidate Policy Interval](#cspNoUpdatesMaxIntervalMinutes)
47-
- [Login Credentials Extraction](#loginCredentialsExtraction)
48-
- [JWT](#JWT)
17+
- [Module Enabled](#moduleEnabled)
18+
- [Module Mode](#moduleMode)
19+
- [Blocking Score](#blockingScore)
20+
- [Send Page Activities](#sendPageActivities)
21+
- [Send Block Activities](#sendBlockActivities)
22+
- [Logger Severity](#loggerSeverity)
23+
- [Sensitive Routes](#sensitiveRoutes)
24+
- [Enforced Specific Routes](#enforcedSpecificRoutes)
25+
- [Monitored Specific Routes](#monitoredSpecificRoutes)
26+
- [Filter By Route](#filterByRoute)
27+
- [Sensitive Headers](#sensitiveHeaders)
28+
- [IP Headers](#ipHeaders)
29+
- [First Party Enabled](#firstPartyEnabled)
30+
- [CD First Party Enabled](#CDFirstPartyEnabled)
31+
- [Custom Request Handler](#customRequestHandler)
32+
- [Additional Activity Handler](#additionalActivityHandler)
33+
- [Enrich Custom Parameters](#enrichCustomParams)
34+
- [CSS Ref](#cssRef)
35+
- [JS Ref](#jsRef)
36+
- [Custom Logo](#customLogo)
37+
- [Secured PXHD cookie](#securedpxhd)
38+
- [Proxy Support](#proxySupport)
39+
- [Custom Cookie Header](#customCookieHeader)
40+
- [Filter Traffic by User Agent](#filterByUserAgent)
41+
- [Filter Traffic by IP](#filterByIP)
42+
- [Filter Traffic by HTTP Method](#filterByMethod)
43+
- [Test Block Flow on Monitoring Mode](#bypassMonitorHeader)
44+
- [CSP Enabled](#cspEnabled)
45+
- [CSP Policy Refresh Interval](#cspPolicyRefreshIntervalMinutes)
46+
- [CSP Invalidate Policy Interval](#cspNoUpdatesMaxIntervalMinutes)
47+
- [Login Credentials Extraction](#loginCredentialsExtraction)
48+
- [JWT](#JWT)
49+
- [CORS support](#px_cors_support)
4950
- [Code Defender Middleware - cdMiddleware](#cdMiddleware)
5051
- [Advanced Blocking Response](#advancedBlockingResponse)
5152
- [Multiple App Support](#multipleAppSupport)
@@ -853,6 +854,85 @@ const pxConfig = {
853854
}
854855
```
855856

857+
#### <a name="px_cors_support"></a>CORS Support
858+
859+
Enable CORS support for the enforcer. This will allow the enforcer to filter out preflight requests and to add CORS headers to block responses.
860+
This will ensure responses are not blocked by the browser.
861+
CORS support is enabled by default.
862+
863+
`px_cors_support_enabled` - Enable CORS support for the enforcer.
864+
865+
**Default:** `false`
866+
867+
`px_cors_custom_preflight_handler` - Custom preflight handler. This function will be called for preflight requests and returns response that will return to the client.
868+
869+
```js
870+
// Example
871+
const pxConfig = {
872+
...
873+
px_cors_custom_preflight_handler: function(request) {
874+
const response = {
875+
status: '204',
876+
};
877+
878+
response.headers = {
879+
'Access-Control-Allow-Origin': request.headers['origin'] || '*',
880+
'Access-Control-Allow-Methods': request.method,
881+
'Access-Control-Allow-Headers': request.headers['access-control-request-headers'],
882+
'Access-Control-Allow-Credentials': 'true',
883+
'Access-Control-Max-Age': '86400',
884+
};
885+
886+
return response;
887+
};
888+
}
889+
```
890+
891+
`px_cors_preflight_request_filter_enabled` - Filter out preflight requests from validation flow.
892+
893+
**Default:** false
894+
895+
Enable CORS support for the enforcer:
896+
``` JS
897+
const pxConfig = {
898+
...
899+
px_cors_support_enabled: true,
900+
px_cors_preflight_request_filter_enabled: true,
901+
...
902+
};
903+
```
904+
905+
The default CORS policy when blocking a request is as follows:
906+
``` JS
907+
Access-Control-Allow-Origin: request origin
908+
Access-Control-Allow-Credentials: true
909+
```
910+
911+
The default CORS policy can be overridden by setting the following properties:
912+
913+
`px_cors_create_custom_block_response_headers`
914+
915+
Synchronous function supplied by the customer which gets the original request and returns an array of custom headers to be added to the block response.
916+
Return type should be an array of objects as follows:
917+
918+
```js
919+
// Example
920+
const pxConfig = {
921+
...
922+
px_cors_create_custom_block_response_headers: function(request) {
923+
return {
924+
'Access-Control-Allow-Origin': request.headers['origin'],
925+
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
926+
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
927+
'Access-Control-Allow-Credentials': 'true'
928+
}
929+
};
930+
...
931+
};
932+
```
933+
934+
**Default:** `null`
935+
856936
## <a name="cdMiddleware"></a> Code Defender Middleware - cdMiddleware
857937

858938
Code Defender's middleware to handle the enforcement of CSP headers on responses returned to the client.
@@ -972,7 +1052,7 @@ server.use('/app2', app1Router);
9721052
server.listen(8081, () => {
9731053
console.log('server started');
9741054
});
975-
```
1055+
``
9761056
9771057
## <a name=“additionalInformation”></a> Additional Information
9781058

lib/pxenforcer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { PxEnforcer, PxCdFirstParty } = require('perimeterx-node-core');
44
const PxExpressClient = require('./pxclient');
55
const PxCdEnforcer = require('./pxcdenforcer');
66

7-
const MODULE_VERSION = 'NodeJS Module v7.5.0';
7+
const MODULE_VERSION = 'NodeJS Module v7.6.0';
88
const MILLISECONDS_IN_MINUTE = 60000;
99

1010
function parseCookies(req, res) {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "perimeterx-node-express",
3-
"version": "7.5.0",
3+
"version": "7.6.0",
44
"description": "PerimeterX Express.js middleware to monitor and block traffic according to PerimeterX risk score",
55
"main": "index.js",
66
"directories": {
@@ -31,7 +31,7 @@
3131
"dependencies": {
3232
"axios": "^0.21.1",
3333
"cookie-parser": "^1.4.1",
34-
"perimeterx-node-core": "^3.8.0"
34+
"perimeterx-node-core": "^3.9.0"
3535
},
3636
"devDependencies": {
3737
"chai": "^4.3.6",

px_metadata.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "7.5.0",
2+
"version": "7.6.0",
33
"supported_features": [
44
"additional_activity_handler",
55
"advanced_blocking_response",
@@ -11,6 +11,7 @@
1111
"block_page_js_challenge",
1212
"bypass_monitor_header",
1313
"client_ip_extraction",
14+
"cors_support",
1415
"csp_support",
1516
"css_ref",
1617
"cookie_v3",

0 commit comments

Comments
 (0)