Skip to content

Commit 225583f

Browse files
docs(upload): add security configuration documentation
1 parent 9f7f990 commit 225583f

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

docusaurus/docs/cms/features/media-library.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ When using the default upload provider, the following specific configuration opt
111111
| `providerOptions.localServer` | Options that will be passed to <ExternalLink to="https://github.com/koajs/static" text="koa-static"/> upon which the Upload server is build (see [local server configuration](#local-server)) | Object | - |
112112
| `sizeLimit` | Maximum file size in bytes (see [max file size](#max-file-size)) | Integer | `209715200`<br/><br/>(200 MB in bytes, i.e., 200 x 1024 x 1024 bytes) |
113113
| `breakpoints` | Allows to override the breakpoints sizes at which responsive images are generated when the "Responsive friendly upload" option is set to `true` (see [responsive images](#responsive-images)) | Object | `{ large: 1000, medium: 750, small: 500 }` |
114+
| `security` | Configures validation rules for uploaded files to enhance media security | Object | - |
114115

115116
:::note
116117
The Upload request timeout is defined in the server options, not in the Upload plugin options, as it's not specific to the Upload plugin but is applied to the whole Strapi server instance (see [upload request timeout](#upload-request-timeout)).
@@ -145,6 +146,10 @@ module.exports = ({ env })=>({
145146
small: 500,
146147
xsmall: 64
147148
},
149+
security: {
150+
allowedTypes: ['image/*', 'application/pdf'],
151+
deniedTypes: ['application/x-sh', 'application/x-dosexec']
152+
},
148153
},
149154
},
150155
});
@@ -171,6 +176,10 @@ export default () => ({
171176
small: 500,
172177
xsmall: 64
173178
},
179+
security: {
180+
allowedTypes: ['image/*', 'application/pdf'],
181+
deniedTypes: ['application/x-sh', 'application/x-dosexec']
182+
},
174183
},
175184
},
176185
})
@@ -319,6 +328,55 @@ export default {
319328

320329
</Tabs>
321330

331+
#### Security
332+
333+
334+
Configures validation rules for uploaded files to enhance media security.
335+
336+
:::note
337+
It's best to define either `allowedTypes` or `deniedTypes`, not both, to avoid conflicts in file validation logic.
338+
:::
339+
340+
You can provide them by creating or editing [the `/config/plugins` file](/cms/configurations/plugins). The following example sets the `allowedTypes` filter:
341+
342+
<Tabs groupId="js-ts">
343+
344+
<TabItem value="javascript" label="JavaScript">
345+
346+
```js title="/config/plugins.js"
347+
module.exports = {
348+
// ...
349+
upload: {
350+
config: {
351+
security: {
352+
allowedTypes: ['image/*', 'application/pdf']
353+
},
354+
}
355+
}
356+
};
357+
```
358+
359+
</TabItem>
360+
361+
<TabItem value="typescript" label="TypeScript">
362+
363+
```js title="/config/plugins.ts"
364+
export default {
365+
// ...
366+
upload: {
367+
config: {
368+
security: {
369+
allowedTypes: ['image/*', 'application/pdf']
370+
},
371+
}
372+
}
373+
};
374+
```
375+
376+
</TabItem>
377+
378+
</Tabs>
379+
322380
#### Upload request timeout
323381

324382
By default, the value of `strapi.server.httpServer.requestTimeout` is set to 330 seconds. This includes uploads.

0 commit comments

Comments
 (0)