You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: backend/forms.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1011,6 +1011,8 @@ Option | Description
1011
1011
1012
1012
> **NOTE:** Unlike the [Media Finder FormWidget](#media-finder), the File Upload FormWidget uses [database file attachments](../database/attachments); so the field name must match a valid `attachOne` or `attachMany` relationship on the Model associated with the Form. **IMPORTANT:** Having a database column with the name used by this field type (i.e. a database column with the name of an existing `attachOne` or `attachMany` relationship) **will** cause this FormWidget to break. Use database columns with the Media Finder FormWidget and file attachment relationships with the File Upload FormWidget.
1013
1013
1014
+
> **Security:** File attachments are public by default. For sensitive files that require access control, set `'public' => false` in your model's attachment relationship configuration. See [Protected Attachments](../database/attachments#protected-attachments) for more information.
1015
+
1014
1016
By default, the File Upload FormWidget only allows a limited set of file extensions. You can extend this list by adding a `fileDefinitions` config in `config/cms.php` file.
1015
1017
See [Allowed file types](../setup/configuration#allowed-file-types) for more information.
1016
1018
@@ -1086,6 +1088,8 @@ Option | Description
1086
1088
1087
1089
> **NOTE:** Unlike the [File Upload FormWidget](#file-upload), the Media Finder FormWidget stores its data as a string representing the path to the image selected within the Media Library.
1088
1090
1091
+
> **Warning:** Files selected from the Media Library are **publicly accessible via direct URL** without any authentication or access control. Do not use the Media Finder for sensitive or private files. For files requiring access control, use the [File Upload FormWidget](#file-upload) with [Protected Attachments](../database/attachments#protected-attachments) instead.
1092
+
1089
1093
### Nested Form
1090
1094
1091
1095
`nestedform`- renders a nested form as the contents of this field and returns the form data as an array.
Copy file name to clipboardExpand all lines: cms/mediamanager.md
+37-1Lines changed: 37 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ By default Media Manager works with the storage/app/media subdirectory of the in
6
6
7
7
Please note that after you change Media Manager configuration, you should reset its cache. You can do that with pressing the **Refresh** button in the Media Manager toolbar.
8
8
9
+
> **Warning:** All files uploaded to the Media Library are **publicly accessible** via direct URL without any authentication. The Media Manager is designed for public assets like theme images, videos, and content that should be accessible to all website visitors. **Do not use the Media Library for sensitive files, user documents, or private content.** For files that require access control, use [File Attachments](../database/attachments) with the `public => false` option instead.
10
+
9
11
## Configuring Amazon S3 access
10
12
11
13
To use Amazon S3 with Winter CMS, you should create S3 bucket, folder in the bucket and API user.
@@ -243,7 +245,7 @@ Parameter | Value
243
245
244
246
### Allowing more specific file extensions
245
247
246
-
By default, the Media Manager only allows a limited set of file extensions. You can extend this list by adding a `fileDefinitions` config in `config/cms.php` file.
248
+
By default, the Media Manager only allows a limited set of file extensions. You can extend this list by adding a `fileDefinitions` config in `config/cms.php` file.
247
249
See [Allowed file types](../setup/configuration#allowed-file-types) for more information.
248
250
249
251
## Events
@@ -279,6 +281,40 @@ Event::listen('media.file.rename', function ($widget, $originalPath, $newPath) {
279
281
});
280
282
```
281
283
284
+
## Security considerations
285
+
286
+
### Public access by default
287
+
288
+
All files stored in the Media Library are publicly accessible via direct URL. This means:
289
+
290
+
-**No authentication required**: Anyone who knows or can guess the file URL can access it
291
+
-**No permission checks**: Backend user permissions do not affect access to media files
292
+
-**Direct browser access**: Files can be accessed directly without going through Winter CMS
293
+
294
+
For local storage, media files are served from `/storage/app/media/` and configured in your web server to be publicly accessible (see [Server Configuration](../setup/configuration) for details).
295
+
296
+
### When to use Media Manager
297
+
298
+
The Media Manager is appropriate for:
299
+
300
+
- Theme assets (images, videos, fonts)
301
+
- Public website content (blog images, product photos, downloadable brochures)
302
+
- Files that are meant to be embedded in CMS pages or layouts
303
+
- Content that should be accessible to all website visitors
304
+
- Files that may be referenced from multiple places in your application
305
+
306
+
### When NOT to use Media Manager
307
+
308
+
**Do not use the Media Manager for:**
309
+
310
+
- User-uploaded documents that should be private
311
+
- Files containing sensitive or confidential information
312
+
- Content that requires authentication or authorization
313
+
- User-specific files (profile pictures, personal documents)
314
+
- Files subject to privacy regulations (GDPR, CCPA, etc.)
315
+
316
+
For these scenarios, use [File Attachments](../database/attachments) with the `public => false` option instead.
317
+
282
318
## Troubleshooting
283
319
284
320
The most common issue with using remote services is the SSL connection problem. If you get SSL errors, make sure that your server has fresh SSL certificates of public Certificate Authorities (CA).
Copy file name to clipboardExpand all lines: database/attachments.md
+31-4Lines changed: 31 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ Winter CMS provides a few different ways to manage files depending on your needs
6
6
7
7
When using the `System\Models\File` model, you are able to configure the disk and paths that are used to store and retrieve the files managed by that model by modifying the `storage.uploads` setting in the [`config/cms.php` file](https://github.com/wintercms/winter/blob/develop/config/cms.php#L317).
8
8
9
+
> **Warning:** File attachments are **public by default** and accessible via direct URL without authentication. To protect sensitive files, you **must explicitly set**`'public' => false` in your attachment configuration. For truly public content that doesn't need database tracking (like theme assets), consider using the [Media Manager](../cms/mediamanager) instead.
10
+
9
11
## File attachments
10
12
11
13
Models can support file attachments using a subset of the [polymorphic relationship](../database/relations#polymorphic-relations). The `$attachOne` or `$attachMany` relations are designed for linking a file to a database record called "attachments". In almost all cases the `System\Models\File` model is used to safekeep this relationship where reference to the files are stored as records in the `system_files` table and have a polymorphic relation to the parent model.
@@ -30,17 +32,40 @@ public $attachMany = [
30
32
31
33
> **NOTE:** If you have a column in your model's table with the same name as the attachment relationship it will not work. Attachments and the FileUpload FormWidget work using relationships, so if there is a column with the same name present in the table itself it will cause issues.
32
34
33
-
Protected attachments are uploaded to the File Upload disk's **uploads/protected** directory which is not accessible for the direct access from the Web. A protected file attachment is defined by setting the *public* argument to `false`:
35
+
### Protected attachments
36
+
37
+
Protected attachments provide access control for sensitive files. Unlike public attachments, protected files cannot be accessed via direct URL and require backend authentication.
38
+
39
+
**Key differences between public and protected attachments:**
40
+
41
+
-**Storage location**: Protected files are stored in `storage/app/uploads/protected/` instead of `storage/app/uploads/public/`
42
+
-**Web server access**: The protected directory is not configured for direct web access in server configuration
43
+
-**Authentication**: Protected files can only be accessed by authenticated backend users with appropriate permissions
44
+
-**URL access**: Protected files are served through Winter CMS's protected file route, not directly from the filesystem
45
+
46
+
**When to use protected attachments:**
47
+
48
+
- User-uploaded documents containing sensitive information
49
+
- Files subject to privacy regulations (GDPR, CCPA, etc.)
50
+
- Content that requires authentication or authorization
51
+
- User-specific files (contracts, invoices, medical records)
52
+
- Any file that should not be publicly accessible
53
+
54
+
**Defining a protected attachment:**
55
+
56
+
Set the `public` argument to `false` in your attachment configuration:
34
57
35
58
```php
36
59
public $attachOne = [
37
-
'avatar' => [
60
+
'confidential_document' => [
38
61
\System\Models\File::class,
39
62
'public' => false,
40
63
],
41
64
];
42
65
```
43
66
67
+
For comparison with other file management approaches, see the [Media Manager security considerations](../cms/mediamanager#security-considerations).
68
+
44
69
### Creating new attachments
45
70
46
71
For singular attach relations (`$attachOne`), you may create an attachment directly via the model relationship, by setting its value using the `Input::file` method, which reads the file data from an input upload.
@@ -74,17 +99,19 @@ foreach ($files as $file) {
74
99
}
75
100
```
76
101
77
-
Alternatively, you can prepare a File model before hand, then manually associate the relationship later. Notice the `is_public` attribute must be set explicitly using this approach.
102
+
Alternatively, you can prepare a File model before hand, then manually associate the relationship later. When creating files this way, the `is_public` attribute must be set explicitly, as it won't automatically inherit from the attachment relationship configuration.
78
103
79
104
```php
80
105
$file = new System\Models\File;
81
106
$file->data = Input::file('file_input');
82
-
$file->is_public = true;
107
+
$file->is_public = true; // Set to false for protected files
83
108
$file->save();
84
109
85
110
$model->avatar()->add($file);
86
111
```
87
112
113
+
> **Note:** Set `is_public` to `true` for publicly accessible files or `false` for protected files that require authentication. When using the relationship's `create()` method (shown earlier), the `is_public` value is automatically determined from the attachment configuration's `public` option.
114
+
88
115
You can also add a file from a URL. To work this method, you need install cURL PHP Extension.
0 commit comments