@reldens/server-utils 0.25.0 → 0.27.0
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/app-server-factory-v2.patch +29 -0
- package/lib/app-server-factory/security-configurer.js +29 -24
- package/lib/app-server-factory.js +521 -499
- package/lib/uploader-factory.js +71 -24
- package/package.json +10 -10
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
--- a/lib/app-server-factory.js
|
|
2
|
+
+++ b/lib/app-server-factory.js
|
|
3
|
+
@@ -141,10 +141,14 @@ class AppServerFactory
|
|
4
|
+
|
|
5
|
+
addHttpDomainsAsDevelopment()
|
|
6
|
+
{
|
|
7
|
+
+ console.log('ENV VARS:', process.env.RELDENS_APP_HOST, process.env.RELDENS_PUBLIC_URL);
|
|
8
|
+
let hostDomain = this.extractDomainFromHttpUrl(process.env.RELDENS_APP_HOST);
|
|
9
|
+
let publicDomain = this.extractDomainFromHttpUrl(process.env.RELDENS_PUBLIC_URL);
|
|
10
|
+
+ console.log('EXTRACTED DOMAINS:', hostDomain, publicDomain);
|
|
11
|
+
if(hostDomain && !this.developmentDomains.includes(hostDomain)){
|
|
12
|
+
this.developmentDomains.push(hostDomain);
|
|
13
|
+
+ console.log('ADDED HOST DOMAIN:', hostDomain);
|
|
14
|
+
}
|
|
15
|
+
if(publicDomain && !this.developmentDomains.includes(publicDomain)){
|
|
16
|
+
this.developmentDomains.push(publicDomain);
|
|
17
|
+
+ console.log('ADDED PUBLIC DOMAIN:', publicDomain);
|
|
18
|
+
}
|
|
19
|
+
+ console.log('FINAL DEVELOPMENT DOMAINS:', this.developmentDomains);
|
|
20
|
+
}
|
|
21
|
+
@@ -154,6 +158,7 @@ class AppServerFactory
|
|
22
|
+
this.isDevelopmentMode = this.developmentModeDetector.detect({
|
|
23
|
+
developmentPatterns: this.developmentPatterns,
|
|
24
|
+
developmentEnvironments: this.developmentEnvironments,
|
|
25
|
+
developmentDomains: this.developmentDomains,
|
|
26
|
+
domains: this.domains
|
|
27
|
+
});
|
|
28
|
+
+ console.log('DEVELOPMENT MODE DETECTED:', this.isDevelopmentMode);
|
|
29
|
+
}
|
|
@@ -27,40 +27,45 @@ class SecurityConfigurer
|
|
|
27
27
|
if(!this.useHelmet){
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
let helmetOptions = {
|
|
30
|
+
let helmetOptions = this.setModeOptions({
|
|
31
31
|
crossOriginEmbedderPolicy: false,
|
|
32
32
|
crossOriginOpenerPolicy: false,
|
|
33
33
|
crossOriginResourcePolicy: false,
|
|
34
34
|
originAgentCluster: false
|
|
35
|
-
};
|
|
35
|
+
}, config);
|
|
36
|
+
if(this.helmetConfig){
|
|
37
|
+
Object.assign(helmetOptions, this.helmetConfig);
|
|
38
|
+
}
|
|
39
|
+
app.use(helmet(helmetOptions));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
setModeOptions(helmetOptions, config)
|
|
43
|
+
{
|
|
36
44
|
if(this.isDevelopmentMode){
|
|
37
45
|
helmetOptions.contentSecurityPolicy = false;
|
|
38
46
|
helmetOptions.hsts = false;
|
|
39
47
|
helmetOptions.noSniff = false;
|
|
40
|
-
|
|
41
|
-
helmetOptions.contentSecurityPolicy = {
|
|
42
|
-
directives: {
|
|
43
|
-
defaultSrc: ["'self'"],
|
|
44
|
-
scriptSrc: ["'self'"],
|
|
45
|
-
scriptSrcElem: ["'self'"],
|
|
46
|
-
styleSrc: ["'self'", "'unsafe-inline'"],
|
|
47
|
-
styleSrcElem: ["'self'", "'unsafe-inline'"],
|
|
48
|
-
imgSrc: ["'self'", "data:", "https:"],
|
|
49
|
-
fontSrc: ["'self'"],
|
|
50
|
-
connectSrc: ["'self'"],
|
|
51
|
-
frameAncestors: ["'none'"],
|
|
52
|
-
baseUri: ["'self'"],
|
|
53
|
-
formAction: ["'self'"]
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
if(config.developmentExternalDomains){
|
|
57
|
-
this.addExternalDomainsToCsp(helmetOptions.contentSecurityPolicy.directives, config.developmentExternalDomains);
|
|
58
|
-
}
|
|
48
|
+
return helmetOptions;
|
|
59
49
|
}
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
helmetOptions.contentSecurityPolicy = {
|
|
51
|
+
directives: {
|
|
52
|
+
defaultSrc: ["'self'"],
|
|
53
|
+
scriptSrc: ["'self'"],
|
|
54
|
+
scriptSrcElem: ["'self'"],
|
|
55
|
+
styleSrc: ["'self'", "'unsafe-inline'"],
|
|
56
|
+
styleSrcElem: ["'self'", "'unsafe-inline'"],
|
|
57
|
+
imgSrc: ["'self'", "data:", "https:"],
|
|
58
|
+
fontSrc: ["'self'"],
|
|
59
|
+
connectSrc: ["'self'"],
|
|
60
|
+
frameAncestors: ["'none'"],
|
|
61
|
+
baseUri: ["'self'"],
|
|
62
|
+
formAction: ["'self'"]
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
if(config.developmentExternalDomains){
|
|
66
|
+
this.addExternalDomainsToCsp(helmetOptions.contentSecurityPolicy.directives, config.developmentExternalDomains);
|
|
62
67
|
}
|
|
63
|
-
|
|
68
|
+
return helmetOptions;
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
addExternalDomainsToCsp(directives, externalDomains)
|