django-nativemojo 0.1.10__py3-none-any.whl

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.
Files changed (194) hide show
  1. django_nativemojo-0.1.10.dist-info/LICENSE +19 -0
  2. django_nativemojo-0.1.10.dist-info/METADATA +96 -0
  3. django_nativemojo-0.1.10.dist-info/NOTICE +8 -0
  4. django_nativemojo-0.1.10.dist-info/RECORD +194 -0
  5. django_nativemojo-0.1.10.dist-info/WHEEL +4 -0
  6. mojo/__init__.py +3 -0
  7. mojo/apps/account/__init__.py +1 -0
  8. mojo/apps/account/admin.py +91 -0
  9. mojo/apps/account/apps.py +16 -0
  10. mojo/apps/account/migrations/0001_initial.py +77 -0
  11. mojo/apps/account/migrations/0002_user_is_email_verified_user_is_phone_verified.py +23 -0
  12. mojo/apps/account/migrations/0003_group_mojo_secrets_user_mojo_secrets.py +23 -0
  13. mojo/apps/account/migrations/__init__.py +0 -0
  14. mojo/apps/account/models/__init__.py +3 -0
  15. mojo/apps/account/models/group.py +98 -0
  16. mojo/apps/account/models/member.py +95 -0
  17. mojo/apps/account/models/pkey.py +18 -0
  18. mojo/apps/account/models/user.py +211 -0
  19. mojo/apps/account/rest/__init__.py +3 -0
  20. mojo/apps/account/rest/group.py +25 -0
  21. mojo/apps/account/rest/user.py +47 -0
  22. mojo/apps/account/utils/__init__.py +0 -0
  23. mojo/apps/account/utils/jwtoken.py +72 -0
  24. mojo/apps/account/utils/passkeys.py +54 -0
  25. mojo/apps/fileman/README.md +549 -0
  26. mojo/apps/fileman/__init__.py +0 -0
  27. mojo/apps/fileman/apps.py +15 -0
  28. mojo/apps/fileman/backends/__init__.py +117 -0
  29. mojo/apps/fileman/backends/base.py +319 -0
  30. mojo/apps/fileman/backends/filesystem.py +397 -0
  31. mojo/apps/fileman/backends/s3.py +398 -0
  32. mojo/apps/fileman/examples/configurations.py +378 -0
  33. mojo/apps/fileman/examples/usage_example.py +665 -0
  34. mojo/apps/fileman/management/__init__.py +1 -0
  35. mojo/apps/fileman/management/commands/__init__.py +1 -0
  36. mojo/apps/fileman/management/commands/cleanup_expired_uploads.py +222 -0
  37. mojo/apps/fileman/models/__init__.py +7 -0
  38. mojo/apps/fileman/models/file.py +292 -0
  39. mojo/apps/fileman/models/manager.py +227 -0
  40. mojo/apps/fileman/models/render.py +0 -0
  41. mojo/apps/fileman/rest/__init__ +0 -0
  42. mojo/apps/fileman/rest/__init__.py +23 -0
  43. mojo/apps/fileman/rest/fileman.py +13 -0
  44. mojo/apps/fileman/rest/upload.py +92 -0
  45. mojo/apps/fileman/utils/__init__.py +19 -0
  46. mojo/apps/fileman/utils/upload.py +616 -0
  47. mojo/apps/incident/__init__.py +1 -0
  48. mojo/apps/incident/handlers/__init__.py +3 -0
  49. mojo/apps/incident/handlers/event_handlers.py +142 -0
  50. mojo/apps/incident/migrations/0001_initial.py +83 -0
  51. mojo/apps/incident/migrations/0002_rename_bundle_ruleset_bundle_minutes_event_hostname_and_more.py +44 -0
  52. mojo/apps/incident/migrations/0003_alter_event_model_id.py +18 -0
  53. mojo/apps/incident/migrations/0004_alter_incident_model_id.py +18 -0
  54. mojo/apps/incident/migrations/__init__.py +0 -0
  55. mojo/apps/incident/models/__init__.py +3 -0
  56. mojo/apps/incident/models/event.py +135 -0
  57. mojo/apps/incident/models/incident.py +33 -0
  58. mojo/apps/incident/models/rule.py +247 -0
  59. mojo/apps/incident/parsers/__init__.py +0 -0
  60. mojo/apps/incident/parsers/ossec/__init__.py +1 -0
  61. mojo/apps/incident/parsers/ossec/core.py +82 -0
  62. mojo/apps/incident/parsers/ossec/parsed.py +23 -0
  63. mojo/apps/incident/parsers/ossec/rules.py +124 -0
  64. mojo/apps/incident/parsers/ossec/utils.py +169 -0
  65. mojo/apps/incident/reporter.py +42 -0
  66. mojo/apps/incident/rest/__init__.py +2 -0
  67. mojo/apps/incident/rest/event.py +23 -0
  68. mojo/apps/incident/rest/ossec.py +22 -0
  69. mojo/apps/logit/__init__.py +0 -0
  70. mojo/apps/logit/admin.py +37 -0
  71. mojo/apps/logit/migrations/0001_initial.py +32 -0
  72. mojo/apps/logit/migrations/0002_log_duid_log_payload_log_username.py +28 -0
  73. mojo/apps/logit/migrations/0003_log_level.py +18 -0
  74. mojo/apps/logit/migrations/__init__.py +0 -0
  75. mojo/apps/logit/models/__init__.py +1 -0
  76. mojo/apps/logit/models/log.py +57 -0
  77. mojo/apps/logit/rest.py +9 -0
  78. mojo/apps/metrics/README.md +79 -0
  79. mojo/apps/metrics/__init__.py +12 -0
  80. mojo/apps/metrics/redis_metrics.py +331 -0
  81. mojo/apps/metrics/rest/__init__.py +1 -0
  82. mojo/apps/metrics/rest/base.py +152 -0
  83. mojo/apps/metrics/rest/db.py +0 -0
  84. mojo/apps/metrics/utils.py +227 -0
  85. mojo/apps/notify/README.md +91 -0
  86. mojo/apps/notify/README_NOTIFICATIONS.md +566 -0
  87. mojo/apps/notify/__init__.py +0 -0
  88. mojo/apps/notify/admin.py +52 -0
  89. mojo/apps/notify/handlers/__init__.py +0 -0
  90. mojo/apps/notify/handlers/example_handlers.py +516 -0
  91. mojo/apps/notify/handlers/ses/__init__.py +25 -0
  92. mojo/apps/notify/handlers/ses/bounce.py +0 -0
  93. mojo/apps/notify/handlers/ses/complaint.py +25 -0
  94. mojo/apps/notify/handlers/ses/message.py +86 -0
  95. mojo/apps/notify/management/__init__.py +0 -0
  96. mojo/apps/notify/management/commands/__init__.py +1 -0
  97. mojo/apps/notify/management/commands/process_notifications.py +370 -0
  98. mojo/apps/notify/mod +0 -0
  99. mojo/apps/notify/models/__init__.py +12 -0
  100. mojo/apps/notify/models/account.py +128 -0
  101. mojo/apps/notify/models/attachment.py +24 -0
  102. mojo/apps/notify/models/bounce.py +68 -0
  103. mojo/apps/notify/models/complaint.py +40 -0
  104. mojo/apps/notify/models/inbox.py +113 -0
  105. mojo/apps/notify/models/inbox_message.py +173 -0
  106. mojo/apps/notify/models/outbox.py +129 -0
  107. mojo/apps/notify/models/outbox_message.py +288 -0
  108. mojo/apps/notify/models/template.py +30 -0
  109. mojo/apps/notify/providers/__init__.py +0 -0
  110. mojo/apps/notify/providers/aws.py +73 -0
  111. mojo/apps/notify/rest/__init__.py +0 -0
  112. mojo/apps/notify/rest/ses.py +0 -0
  113. mojo/apps/notify/utils/__init__.py +2 -0
  114. mojo/apps/notify/utils/notifications.py +404 -0
  115. mojo/apps/notify/utils/parsing.py +202 -0
  116. mojo/apps/notify/utils/render.py +144 -0
  117. mojo/apps/tasks/README.md +118 -0
  118. mojo/apps/tasks/__init__.py +11 -0
  119. mojo/apps/tasks/manager.py +489 -0
  120. mojo/apps/tasks/rest/__init__.py +2 -0
  121. mojo/apps/tasks/rest/hooks.py +0 -0
  122. mojo/apps/tasks/rest/tasks.py +62 -0
  123. mojo/apps/tasks/runner.py +174 -0
  124. mojo/apps/tasks/tq_handlers.py +14 -0
  125. mojo/decorators/__init__.py +3 -0
  126. mojo/decorators/auth.py +25 -0
  127. mojo/decorators/cron.py +31 -0
  128. mojo/decorators/http.py +132 -0
  129. mojo/decorators/validate.py +14 -0
  130. mojo/errors.py +88 -0
  131. mojo/helpers/__init__.py +0 -0
  132. mojo/helpers/aws/__init__.py +0 -0
  133. mojo/helpers/aws/client.py +8 -0
  134. mojo/helpers/aws/s3.py +268 -0
  135. mojo/helpers/aws/setup_email.py +0 -0
  136. mojo/helpers/cron.py +79 -0
  137. mojo/helpers/crypto/__init__.py +4 -0
  138. mojo/helpers/crypto/aes.py +60 -0
  139. mojo/helpers/crypto/hash.py +59 -0
  140. mojo/helpers/crypto/privpub/__init__.py +1 -0
  141. mojo/helpers/crypto/privpub/hybrid.py +97 -0
  142. mojo/helpers/crypto/privpub/rsa.py +104 -0
  143. mojo/helpers/crypto/sign.py +36 -0
  144. mojo/helpers/crypto/too.l.py +25 -0
  145. mojo/helpers/crypto/utils.py +26 -0
  146. mojo/helpers/daemon.py +94 -0
  147. mojo/helpers/dates.py +69 -0
  148. mojo/helpers/dns/__init__.py +0 -0
  149. mojo/helpers/dns/godaddy.py +62 -0
  150. mojo/helpers/filetypes.py +128 -0
  151. mojo/helpers/logit.py +310 -0
  152. mojo/helpers/modules.py +95 -0
  153. mojo/helpers/paths.py +63 -0
  154. mojo/helpers/redis.py +10 -0
  155. mojo/helpers/request.py +89 -0
  156. mojo/helpers/request_parser.py +269 -0
  157. mojo/helpers/response.py +14 -0
  158. mojo/helpers/settings.py +146 -0
  159. mojo/helpers/sysinfo.py +140 -0
  160. mojo/helpers/ua.py +0 -0
  161. mojo/middleware/__init__.py +0 -0
  162. mojo/middleware/auth.py +26 -0
  163. mojo/middleware/logging.py +55 -0
  164. mojo/middleware/mojo.py +21 -0
  165. mojo/migrations/0001_initial.py +32 -0
  166. mojo/migrations/__init__.py +0 -0
  167. mojo/models/__init__.py +2 -0
  168. mojo/models/meta.py +262 -0
  169. mojo/models/rest.py +538 -0
  170. mojo/models/secrets.py +59 -0
  171. mojo/rest/__init__.py +1 -0
  172. mojo/rest/info.py +26 -0
  173. mojo/serializers/__init__.py +0 -0
  174. mojo/serializers/models.py +165 -0
  175. mojo/serializers/openapi.py +188 -0
  176. mojo/urls.py +38 -0
  177. mojo/ws4redis/README.md +174 -0
  178. mojo/ws4redis/__init__.py +2 -0
  179. mojo/ws4redis/client.py +283 -0
  180. mojo/ws4redis/connection.py +327 -0
  181. mojo/ws4redis/exceptions.py +32 -0
  182. mojo/ws4redis/redis.py +183 -0
  183. mojo/ws4redis/servers/__init__.py +0 -0
  184. mojo/ws4redis/servers/base.py +86 -0
  185. mojo/ws4redis/servers/django.py +171 -0
  186. mojo/ws4redis/servers/uwsgi.py +63 -0
  187. mojo/ws4redis/settings.py +45 -0
  188. mojo/ws4redis/utf8validator.py +128 -0
  189. mojo/ws4redis/websocket.py +403 -0
  190. testit/__init__.py +0 -0
  191. testit/client.py +147 -0
  192. testit/faker.py +20 -0
  193. testit/helpers.py +198 -0
  194. testit/runner.py +262 -0
@@ -0,0 +1,378 @@
1
+ """
2
+ Example configurations for FileManager storage backends
3
+
4
+ This file contains example configurations for different storage backends
5
+ that can be used with the fileman app. Copy and modify these examples
6
+ to suit your specific needs.
7
+ """
8
+
9
+ # Example S3 configurations
10
+ S3_CONFIGURATIONS = {
11
+ # Basic S3 configuration
12
+ "s3_basic": {
13
+ "name": "AWS S3 Production",
14
+ "description": "Production S3 storage for file uploads",
15
+ "backend_type": "s3",
16
+ "backend_url": "s3://my-app-files/",
17
+ "supports_direct_upload": True,
18
+ "max_file_size": 100 * 1024 * 1024, # 100MB
19
+ "allowed_extensions": ["pdf", "doc", "docx", "jpg", "png", "gif"],
20
+ "allowed_mime_types": [
21
+ "application/pdf",
22
+ "application/msword",
23
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
24
+ "image/jpeg",
25
+ "image/png",
26
+ "image/gif"
27
+ ],
28
+ "settings": {
29
+ "bucket_name": "my-app-files",
30
+ "region_name": "us-east-1",
31
+ "access_key_id": "AKIAIOSFODNN7EXAMPLE", # Use environment variables in production
32
+ "secret_access_key": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", # Use environment variables
33
+ "upload_expires_in": 3600, # 1 hour
34
+ "download_expires_in": 3600, # 1 hour
35
+ "server_side_encryption": "AES256", # or "aws:kms"
36
+ "signature_version": "s3v4",
37
+ "addressing_style": "auto"
38
+ }
39
+ },
40
+
41
+ # S3 with KMS encryption
42
+ "s3_encrypted": {
43
+ "name": "AWS S3 with KMS Encryption",
44
+ "description": "S3 storage with KMS encryption for sensitive files",
45
+ "backend_type": "s3",
46
+ "backend_url": "s3://secure-files/",
47
+ "supports_direct_upload": True,
48
+ "max_file_size": 50 * 1024 * 1024, # 50MB
49
+ "settings": {
50
+ "bucket_name": "secure-files",
51
+ "region_name": "us-west-2",
52
+ "access_key_id": "AKIAIOSFODNN7EXAMPLE",
53
+ "secret_access_key": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
54
+ "server_side_encryption": "aws:kms",
55
+ "kms_key_id": "arn:aws:kms:us-west-2:123456789012:key/12345678-1234-1234-1234-123456789012",
56
+ "upload_expires_in": 1800, # 30 minutes
57
+ "download_expires_in": 300, # 5 minutes
58
+ }
59
+ },
60
+
61
+ # S3-compatible service (like MinIO, DigitalOcean Spaces)
62
+ "s3_compatible": {
63
+ "name": "DigitalOcean Spaces",
64
+ "description": "DigitalOcean Spaces storage",
65
+ "backend_type": "s3",
66
+ "backend_url": "https://nyc3.digitaloceanspaces.com/my-space/",
67
+ "supports_direct_upload": True,
68
+ "settings": {
69
+ "bucket_name": "my-space",
70
+ "region_name": "nyc3",
71
+ "endpoint_url": "https://nyc3.digitaloceanspaces.com",
72
+ "access_key_id": "DO00EXAMPLE",
73
+ "secret_access_key": "EXAMPLE_SECRET_KEY",
74
+ "signature_version": "s3v4",
75
+ "addressing_style": "auto"
76
+ }
77
+ }
78
+ }
79
+
80
+ # Example File System configurations
81
+ FILESYSTEM_CONFIGURATIONS = {
82
+ # Basic filesystem configuration
83
+ "filesystem_basic": {
84
+ "name": "Local File Storage",
85
+ "description": "Local file system storage for development",
86
+ "backend_type": "file",
87
+ "backend_url": "file:///app/media/uploads/",
88
+ "supports_direct_upload": False, # Filesystem backend uses custom upload endpoint
89
+ "max_file_size": 10 * 1024 * 1024, # 10MB
90
+ "settings": {
91
+ "base_path": "/app/media/uploads",
92
+ "base_url": "/media/uploads/",
93
+ "create_directories": True,
94
+ "permissions": 0o644,
95
+ "directory_permissions": 0o755,
96
+ "temp_upload_path": "/app/media/temp",
97
+ "upload_expires_in": 3600
98
+ }
99
+ },
100
+
101
+ # Filesystem with different organization
102
+ "filesystem_organized": {
103
+ "name": "Organized File Storage",
104
+ "description": "File system storage with date-based organization",
105
+ "backend_type": "file",
106
+ "backend_url": "file:///var/uploads/",
107
+ "supports_direct_upload": False,
108
+ "max_file_size": 100 * 1024 * 1024, # 100MB
109
+ "allowed_extensions": ["pdf", "doc", "docx", "txt", "csv"],
110
+ "settings": {
111
+ "base_path": "/var/uploads",
112
+ "base_url": "/uploads/",
113
+ "create_directories": True,
114
+ "permissions": 0o644,
115
+ "directory_permissions": 0o755,
116
+ "temp_upload_path": "/var/uploads/temp"
117
+ }
118
+ }
119
+ }
120
+
121
+ # Development configurations
122
+ DEVELOPMENT_CONFIGURATIONS = {
123
+ "dev_local": {
124
+ "name": "Development Local Storage",
125
+ "description": "Local development file storage",
126
+ "backend_type": "file",
127
+ "backend_url": "file://./dev_uploads/",
128
+ "supports_direct_upload": False,
129
+ "max_file_size": 50 * 1024 * 1024, # 50MB
130
+ "is_default": True,
131
+ "settings": {
132
+ "base_path": "./dev_uploads",
133
+ "base_url": "/dev_uploads/",
134
+ "create_directories": True,
135
+ "permissions": 0o644,
136
+ "directory_permissions": 0o755
137
+ }
138
+ },
139
+
140
+ "dev_s3": {
141
+ "name": "Development S3 (MinIO)",
142
+ "description": "Local MinIO for S3 development testing",
143
+ "backend_type": "s3",
144
+ "backend_url": "s3://dev-bucket/",
145
+ "supports_direct_upload": True,
146
+ "max_file_size": 10 * 1024 * 1024, # 10MB
147
+ "settings": {
148
+ "bucket_name": "dev-bucket",
149
+ "region_name": "us-east-1",
150
+ "endpoint_url": "http://localhost:9000", # MinIO default
151
+ "access_key_id": "minioadmin",
152
+ "secret_access_key": "minioadmin",
153
+ "signature_version": "s3v4"
154
+ }
155
+ }
156
+ }
157
+
158
+ # Production configurations
159
+ PRODUCTION_CONFIGURATIONS = {
160
+ "prod_s3_primary": {
161
+ "name": "Production S3 Primary",
162
+ "description": "Primary production S3 storage",
163
+ "backend_type": "s3",
164
+ "backend_url": "s3://prod-files-primary/",
165
+ "supports_direct_upload": True,
166
+ "max_file_size": 500 * 1024 * 1024, # 500MB
167
+ "is_default": True,
168
+ "allowed_extensions": [
169
+ "pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx",
170
+ "jpg", "jpeg", "png", "gif", "svg", "webp",
171
+ "mp4", "webm", "avi", "mov",
172
+ "zip", "tar", "gz", "rar"
173
+ ],
174
+ "settings": {
175
+ "bucket_name": "prod-files-primary",
176
+ "region_name": "us-east-1",
177
+ "access_key_id": "${AWS_ACCESS_KEY_ID}", # Use environment variables
178
+ "secret_access_key": "${AWS_SECRET_ACCESS_KEY}",
179
+ "server_side_encryption": "AES256",
180
+ "upload_expires_in": 7200, # 2 hours
181
+ "download_expires_in": 3600, # 1 hour
182
+ "multipart_threshold": 8 * 1024 * 1024, # 8MB
183
+ "max_concurrency": 10
184
+ }
185
+ },
186
+
187
+ "prod_s3_backup": {
188
+ "name": "Production S3 Backup",
189
+ "description": "Backup S3 storage in different region",
190
+ "backend_type": "s3",
191
+ "backend_url": "s3://prod-files-backup/",
192
+ "supports_direct_upload": True,
193
+ "max_file_size": 500 * 1024 * 1024, # 500MB
194
+ "settings": {
195
+ "bucket_name": "prod-files-backup",
196
+ "region_name": "us-west-2", # Different region for redundancy
197
+ "access_key_id": "${AWS_ACCESS_KEY_ID}",
198
+ "secret_access_key": "${AWS_SECRET_ACCESS_KEY}",
199
+ "server_side_encryption": "AES256"
200
+ }
201
+ }
202
+ }
203
+
204
+ # Specialized configurations
205
+ SPECIALIZED_CONFIGURATIONS = {
206
+ "images_only": {
207
+ "name": "Images Only Storage",
208
+ "description": "Storage specifically for image files",
209
+ "backend_type": "s3",
210
+ "backend_url": "s3://app-images/",
211
+ "supports_direct_upload": True,
212
+ "max_file_size": 20 * 1024 * 1024, # 20MB
213
+ "allowed_extensions": ["jpg", "jpeg", "png", "gif", "webp", "svg"],
214
+ "allowed_mime_types": [
215
+ "image/jpeg",
216
+ "image/png",
217
+ "image/gif",
218
+ "image/webp",
219
+ "image/svg+xml"
220
+ ],
221
+ "settings": {
222
+ "bucket_name": "app-images",
223
+ "region_name": "us-east-1",
224
+ "access_key_id": "${AWS_ACCESS_KEY_ID}",
225
+ "secret_access_key": "${AWS_SECRET_ACCESS_KEY}",
226
+ "upload_expires_in": 1800, # 30 minutes
227
+ "download_expires_in": 86400 # 24 hours (for CDN caching)
228
+ }
229
+ },
230
+
231
+ "documents_secure": {
232
+ "name": "Secure Documents",
233
+ "description": "Encrypted storage for sensitive documents",
234
+ "backend_type": "s3",
235
+ "backend_url": "s3://secure-docs/",
236
+ "supports_direct_upload": True,
237
+ "max_file_size": 100 * 1024 * 1024, # 100MB
238
+ "allowed_extensions": ["pdf", "doc", "docx"],
239
+ "allowed_mime_types": [
240
+ "application/pdf",
241
+ "application/msword",
242
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
243
+ ],
244
+ "is_public": False,
245
+ "settings": {
246
+ "bucket_name": "secure-docs",
247
+ "region_name": "us-east-1",
248
+ "access_key_id": "${AWS_ACCESS_KEY_ID}",
249
+ "secret_access_key": "${AWS_SECRET_ACCESS_KEY}",
250
+ "server_side_encryption": "aws:kms",
251
+ "kms_key_id": "${KMS_KEY_ID}",
252
+ "upload_expires_in": 600, # 10 minutes
253
+ "download_expires_in": 300 # 5 minutes
254
+ }
255
+ },
256
+
257
+ "temp_uploads": {
258
+ "name": "Temporary Uploads",
259
+ "description": "Short-term storage for temporary files",
260
+ "backend_type": "file",
261
+ "backend_url": "file:///tmp/uploads/",
262
+ "supports_direct_upload": False,
263
+ "max_file_size": 50 * 1024 * 1024, # 50MB
264
+ "settings": {
265
+ "base_path": "/tmp/uploads",
266
+ "base_url": "/temp/",
267
+ "create_directories": True,
268
+ "upload_expires_in": 1800, # 30 minutes
269
+ "permissions": 0o600, # More restrictive permissions
270
+ "directory_permissions": 0o700
271
+ }
272
+ }
273
+ }
274
+
275
+ # Environment-based configuration function
276
+ def get_configuration_for_environment(env="development"):
277
+ """
278
+ Get appropriate configuration based on environment
279
+
280
+ Args:
281
+ env: Environment name ("development", "staging", "production")
282
+
283
+ Returns:
284
+ dict: Configuration dictionary
285
+ """
286
+ if env == "development":
287
+ return DEVELOPMENT_CONFIGURATIONS["dev_local"]
288
+ elif env == "staging":
289
+ # Use production-like S3 but with smaller limits
290
+ config = PRODUCTION_CONFIGURATIONS["prod_s3_primary"].copy()
291
+ config["name"] = "Staging S3 Storage"
292
+ config["description"] = "Staging environment S3 storage"
293
+ config["max_file_size"] = 100 * 1024 * 1024 # 100MB instead of 500MB
294
+ config["settings"]["bucket_name"] = "staging-files"
295
+ return config
296
+ elif env == "production":
297
+ return PRODUCTION_CONFIGURATIONS["prod_s3_primary"]
298
+ else:
299
+ raise ValueError(f"Unknown environment: {env}")
300
+
301
+ # Usage examples for Django management commands or admin
302
+ """
303
+ # Example: Create FileManager instances from configurations
304
+
305
+ from mojo.apps.fileman.models import FileManager
306
+ from mojo.apps.account.models import Group
307
+
308
+ # Get or create a group
309
+ group, created = Group.objects.get_or_create(name="Default Group")
310
+
311
+ # Create a file manager from configuration
312
+ config = PRODUCTION_CONFIGURATIONS["prod_s3_primary"]
313
+ file_manager = FileManager.objects.create(
314
+ group=group,
315
+ name=config["name"],
316
+ description=config["description"],
317
+ backend_type=config["backend_type"],
318
+ backend_url=config["backend_url"],
319
+ supports_direct_upload=config["supports_direct_upload"],
320
+ max_file_size=config["max_file_size"],
321
+ allowed_extensions=config.get("allowed_extensions", []),
322
+ allowed_mime_types=config.get("allowed_mime_types", []),
323
+ settings=config["settings"],
324
+ is_default=config.get("is_default", False),
325
+ is_active=True
326
+ )
327
+ """
328
+
329
+ # Environment variables that should be set in production
330
+ REQUIRED_ENVIRONMENT_VARIABLES = {
331
+ "s3": [
332
+ "AWS_ACCESS_KEY_ID",
333
+ "AWS_SECRET_ACCESS_KEY",
334
+ "AWS_DEFAULT_REGION", # Optional but recommended
335
+ "KMS_KEY_ID" # If using KMS encryption
336
+ ],
337
+ "file": [
338
+ "UPLOAD_ROOT_PATH", # Base path for file uploads
339
+ "MEDIA_URL" # URL prefix for serving files
340
+ ]
341
+ }
342
+
343
+ # Security recommendations
344
+ SECURITY_RECOMMENDATIONS = """
345
+ Security Best Practices for File Management:
346
+
347
+ 1. S3 Configuration:
348
+ - Never hardcode AWS credentials in your code
349
+ - Use IAM roles when running on EC2/ECS
350
+ - Use environment variables or AWS Secrets Manager
351
+ - Enable bucket versioning and lifecycle policies
352
+ - Use least-privilege IAM policies
353
+ - Consider enabling MFA delete for critical buckets
354
+
355
+ 2. File Validation:
356
+ - Always validate file extensions and MIME types
357
+ - Set reasonable file size limits
358
+ - Scan files for malware if accepting user uploads
359
+ - Use Content Security Policy headers when serving files
360
+
361
+ 3. Access Control:
362
+ - Implement proper authentication and authorization
363
+ - Use signed URLs with appropriate expiration times
364
+ - Consider IP restrictions for sensitive files
365
+ - Log all file access attempts
366
+
367
+ 4. Data Protection:
368
+ - Use encryption at rest (S3 server-side encryption)
369
+ - Use encryption in transit (HTTPS)
370
+ - Consider client-side encryption for highly sensitive data
371
+ - Implement proper backup and disaster recovery
372
+
373
+ 5. Monitoring:
374
+ - Monitor upload/download patterns
375
+ - Set up alerts for unusual activity
376
+ - Track storage costs and usage
377
+ - Log all file operations for audit trails
378
+ """