-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Django storage backend to handle file-upload to s3 storage #390
Merged
Merged
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f396a7a
feat!(storage): use Django's storage backend for object storage
fugal-dy 55bc185
refactor(checksum): move checksum logic to model
fugal-dy 922f55a
feat(files): add signed download_url to file
fugal-dy 26c4331
fix(document): adjust cloning for use with storage backends
fugal-dy b5817c2
fix(migration): make choices class available during migration
fugal-dy 5e8f8bb
fix: various changes address in review
fugal-dy fdb5943
refactor(signed-url): move url signing and verifcation to own module
fugal-dy b753c18
Merge branch 'main' into feat-upload-file-to-s3storage
Yelinz 19ca896
fix: fix tests
Yelinz ac4a910
feat: add command to encrypt existing files
Yelinz 2ae692b
chore(deps-dev): bump gitpython from 3.1.40 to 3.1.41 (#414)
dependabot[bot] 7887c62
feat(document): update modfied data when creating new file (#416)
Yelinz c8e67b7
chore: v3.0.0-beta.2 (#417)
Yelinz 43c220e
fix: various small fixes for ssec
Yelinz 4f39f90
Merge branch 'main' into feat-upload-file-to-s3storage
Yelinz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Generated by Django 3.2.23 on 2023-12-13 18:00 | ||
|
||
from django.db import migrations, models | ||
|
||
import alexandria.core.models | ||
import alexandria.storages.fields | ||
|
||
|
||
def migrate_file_references(apps, schema_editor): | ||
"""Migrate the download_url based content access to storage backend access. | ||
|
||
The simple object storage's object_name was simply the file's name. Setting | ||
the name to the file name in the storage attribute will refer retrieve | ||
the same object if it still exists. | ||
Just make sure to point the object storage client to the right endpoint | ||
and bucket before accessing the file. | ||
""" | ||
File = apps.get_model("alexandria_core", "File") | ||
for file in File.objects.iterator(): | ||
file.content.name = alexandria.core.models.upload_file_content_to(file, None) | ||
file.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("alexandria_core", "0010_mark"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="file", | ||
name="upload_status", | ||
), | ||
migrations.AddField( | ||
model_name="file", | ||
name="content", | ||
field=alexandria.storages.fields.DynamicStorageFileField( | ||
default="", upload_to=alexandria.core.models.upload_file_content_to | ||
), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name="file", | ||
name="encryption_status", | ||
field=models.CharField( | ||
blank=True, | ||
choices=[ | ||
(None, "Encryption status not set"), | ||
("none", "No at-rest enryption"), | ||
("ssec-global", "SSE-C global key encryption (AES256)"), | ||
("ssec-object", "SSE-C per object encryption (AES256)"), | ||
], | ||
default=None, | ||
max_length=12, | ||
null=True, | ||
), | ||
), | ||
migrations.RunPython(migrate_file_references, migrations.RunPython.noop), | ||
] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is dangerous. Enabling encryption should force you to configure everything needed. You shouldn't be able to set
ALEXANDRIA_ENABLE_AT_REST_ENCRYPTION=True
and allow unencrypted files to be storedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a check
alexandria/alexandria/storages/fields.py
Lines 39 to 42 in e941029
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! But now the docs are not accurate anymore :-)