@cloudimage-strapi/content-plugin 1.0.0 → 1.0.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 +0 -22
- package/admin/src/pages/HomePage/index.js +1 -1
- package/package.json +1 -4
- package/server/bootstrap.js +21 -1
- package/server/register.js +53 -53
- package/server/services/scaleflex-cloudimage.js +0 -15
package/README.md
CHANGED
|
@@ -6,28 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
## Config
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
`config/middlewares.js`
|
|
11
|
-
|
|
12
|
-
Replace `'strapi::security',` with:
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
{
|
|
16
|
-
name: 'strapi::security',
|
|
17
|
-
config: {
|
|
18
|
-
contentSecurityPolicy: {
|
|
19
|
-
useDefaults: true,
|
|
20
|
-
directives: {
|
|
21
|
-
'connect-src': ["'self'", 'https:'],
|
|
22
|
-
'img-src': ["'self'", 'data:', 'blob:', 'scaleflex.cloudimg.io', 'assets.scaleflex.com', '*.cloudimg.io'],
|
|
23
|
-
'media-src': ["'self'", 'data:', 'blob:', 'scaleflex.cloudimg.io', 'assets.scaleflex.com', '*.cloudimg.io'],
|
|
24
|
-
upgradeInsecureRequests: null,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
```
|
|
30
|
-
|
|
31
9
|
`config/server.js`
|
|
32
10
|
|
|
33
11
|
Append `url: 'domain (including the http/https:// part)'`
|
|
@@ -164,7 +164,7 @@ const HomePage = () => {
|
|
|
164
164
|
{(updateCount <= 0) ? 'None are to be updated.' : updateMessage}
|
|
165
165
|
</Alert>
|
|
166
166
|
)}
|
|
167
|
-
<Box
|
|
167
|
+
<Box paddingTop={5} paddingRight={8}>
|
|
168
168
|
<Typography variant={'alpha'}>Cloudimage by Scaleflex</Typography>
|
|
169
169
|
</Box>
|
|
170
170
|
<Field name="domain">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudimage-strapi/content-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Strapi v4 plugin for Filerobot by Scaleflex",
|
|
5
5
|
"strapi": {
|
|
6
6
|
"name": "scaleflex-cloudimage",
|
|
@@ -8,9 +8,6 @@
|
|
|
8
8
|
"kind": "plugin",
|
|
9
9
|
"displayName": "Scaleflex Cloudimage"
|
|
10
10
|
},
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"@strapi/design-system": "^1.4.1"
|
|
13
|
-
},
|
|
14
11
|
"peerDependencies": {
|
|
15
12
|
"@strapi/strapi": "^4.3.0"
|
|
16
13
|
},
|
package/server/bootstrap.js
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
module.exports = ({ strapi }) => {
|
|
4
|
-
|
|
4
|
+
strapi.store({
|
|
5
|
+
environment: strapi.config.environment,
|
|
6
|
+
type: 'plugin',
|
|
7
|
+
name: 'cloudimage',
|
|
8
|
+
})
|
|
9
|
+
.get({key: 'options'})
|
|
10
|
+
.then((config) => {
|
|
11
|
+
if (config && config.hasOwnProperty('domain') && config.domain)
|
|
12
|
+
{
|
|
13
|
+
for (let index = 1; index < strapi.config.middlewares.length; index++)
|
|
14
|
+
{
|
|
15
|
+
let item = strapi.config.middlewares[index];
|
|
16
|
+
|
|
17
|
+
if (typeof item === 'object' && item.name === 'strapi::security' && !item.config.contentSecurityPolicy.directives['img-src'].includes(config.domain))
|
|
18
|
+
{
|
|
19
|
+
strapi.config.middlewares[index].config.contentSecurityPolicy.directives['img-src'].push(config.domain);
|
|
20
|
+
strapi.config.middlewares[index].config.contentSecurityPolicy.directives['media-src'].push(config.domain);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
5
25
|
};
|
package/server/register.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
module.exports = ({ strapi }) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
const pluginMiddleware = {
|
|
5
|
+
name: 'strapi::security',
|
|
6
|
+
config: {
|
|
7
|
+
contentSecurityPolicy: {
|
|
8
|
+
useDefaults: true,
|
|
9
|
+
directives: {
|
|
10
|
+
'connect-src': ["'self'", 'https:'],
|
|
11
|
+
'img-src': ["'self'", 'data:', 'blob:', 'scaleflex.cloudimg.io', 'assets.scaleflex.com', '*.cloudimg.io'],
|
|
12
|
+
'media-src': ["'self'", 'data:', 'blob:', 'scaleflex.cloudimg.io', 'assets.scaleflex.com', '*.cloudimg.io'],
|
|
13
|
+
upgradeInsecureRequests: null,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
18
|
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
// Merge a `source` object to a `target` recursively
|
|
20
|
+
const merge = (target, source) => {
|
|
21
|
+
// Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties
|
|
22
|
+
for (const key of Object.keys(source))
|
|
23
|
+
{
|
|
24
|
+
if (Array.isArray(source[key]))
|
|
25
|
+
{
|
|
26
|
+
Object.assign(source[key], [...new Set(target[key].concat(source[key]))]);
|
|
27
|
+
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
if (source[key] instanceof Object && !Array.isArray(source[key]))
|
|
30
|
+
{
|
|
31
|
+
Object.assign(source[key], merge(target[key], source[key]));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
34
|
|
|
35
|
-
//
|
|
36
|
-
|
|
35
|
+
// Join `target` and modified `source`
|
|
36
|
+
Object.assign(target || {}, source);
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
return target;
|
|
39
|
+
};
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
for (let index = 1; index < strapi.config.middlewares.length; index++)
|
|
42
|
+
{
|
|
43
|
+
let item = strapi.config.middlewares[index];
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
if (typeof item === 'object' && item.name === 'strapi::security')
|
|
46
|
+
{
|
|
47
|
+
let mergedSettings = merge(item.config, pluginMiddleware.config);
|
|
48
|
+
strapi.config.middlewares.splice(index, 1, {name: 'strapi::security', config: mergedSettings});
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
else if (typeof item === 'string' && item === 'strapi::security')
|
|
53
|
+
{
|
|
54
|
+
strapi.config.middlewares.splice(index, 1, pluginMiddleware);
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
else
|
|
59
|
+
{
|
|
60
|
+
strapi.config.middlewares.push(pluginMiddleware);
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
65
|
};
|
|
@@ -40,21 +40,6 @@ module.exports = ({ strapi }) => ({
|
|
|
40
40
|
|
|
41
41
|
const config = await pluginStore.get({key: 'options'});
|
|
42
42
|
|
|
43
|
-
// if (config.domain)
|
|
44
|
-
// {
|
|
45
|
-
// for (let index = 1; index < strapi.config.middlewares.length; index++)
|
|
46
|
-
// {
|
|
47
|
-
// let item = strapi.config.middlewares[index];
|
|
48
|
-
|
|
49
|
-
// if (typeof item === 'object' && item.name === 'strapi::security'
|
|
50
|
-
// && !item.config.contentSecurityPolicy.directives['img-src'].includes(config.domain))
|
|
51
|
-
// {
|
|
52
|
-
// strapi.config.middlewares[index].config.contentSecurityPolicy.directives['img-src'].push(config.domain);
|
|
53
|
-
// strapi.config.middlewares[index].config.contentSecurityPolicy.directives['media-src'].push(config.domain);
|
|
54
|
-
// }
|
|
55
|
-
// }
|
|
56
|
-
// }
|
|
57
|
-
|
|
58
43
|
return config;
|
|
59
44
|
},
|
|
60
45
|
async checkV7(ctx) {
|