-
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
Conversation
if (original := self.initial_data.get("original")) and not isinstance( | ||
original, dict | ||
): | ||
self.initial_data["original"] = {"type": "files", "id": original} |
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.
Would this get any easier with the help of FormDataResourceRelatedField
? See https://github.com/inosca/ebau/blob/main/django/camac/relations.py#L5
e1a76ba
to
864630b
Compare
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.
Found a few issues in the code, but mainly smaller ones. The big issues however are:
- Did you verify the data uploaded in the old way is still accessible after the update? That needs to work absolutely certainly, otherwise we'll need a migration of sorts.
- I would like to see the virtualenv/poetry stuff split out into it's own merge request, so we can discuss it separately. I'm not 100% convinced it's the right way, but willing to discuss
- And last: The change needs to be marked breaking, as it's entirely different config, and entirely different way of accessing data for the frontend
16af39a
to
4ac5401
Compare
41291e8
to
2d87a24
Compare
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 work so far, getting there!
I'd like to see the whole encryption thing to be optional and controllable via settings. Right now you can't really have unencrypted files in S3
5bb47e5
to
b8c09fe
Compare
99068a1
to
d2f714d
Compare
bdc3b06
to
f91fd43
Compare
f91fd43
to
e380f1a
Compare
e380f1a
to
a26a939
Compare
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 work! I think after some final cleanup, this is on a good track 👍
README.md
Outdated
- `FILE_STORAGE_BACKEND`: Set the backend for file uploads. `django-storages` is available (default: `django.core.files.storage.FileSystemStorage`) | ||
|
||
Encryption: | ||
- `ALEXANDRIA_ENABLE_AT_REST_ENCRYPTION`: Set to `true` to enable at-rest encryption of files (does nothing by itself unless `ALEXANDRIA_ENCRYPTRION_METHOD` is set to a supported method) |
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 stored
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.
Added a check
alexandria/alexandria/storages/fields.py
Lines 39 to 42 in e941029
elif method == File.EncryptionStatus.NOT_ENCRYPTED: | |
raise ImproperlyConfigured( | |
"ALEXANDRIA_ENCRYPTION_METHOD is set to NOT_ENCRYPTED while ALEXANDRIA_ENABLE_AT_REST_ENCRYPTION is enabled." | |
) |
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 :-)
- `ALEXANDRIA_ENABLE_AT_REST_ENCRYPTION`: Set to `true` to enable at-rest encryption of files (does nothing by itself unless `ALEXANDRIA_ENCRYPTRION_METHOD` is set to a supported method) | |
- `ALEXANDRIA_ENABLE_AT_REST_ENCRYPTION`: Set to `true` to enable at-rest encryption of files (enabling this causes an error unless `ALEXANDRIA_ENCRYPTRION_METHOD` is set to a supported method) |
de1faa2
to
2875125
Compare
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.
Any minute now :-)
README.md
Outdated
- `FILE_STORAGE_BACKEND`: Set the backend for file uploads. `django-storages` is available (default: `django.core.files.storage.FileSystemStorage`) | ||
|
||
Encryption: | ||
- `ALEXANDRIA_ENABLE_AT_REST_ENCRYPTION`: Set to `true` to enable at-rest encryption of files (does nothing by itself unless `ALEXANDRIA_ENCRYPTRION_METHOD` is set to a supported method) |
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 :-)
- `ALEXANDRIA_ENABLE_AT_REST_ENCRYPTION`: Set to `true` to enable at-rest encryption of files (does nothing by itself unless `ALEXANDRIA_ENCRYPTRION_METHOD` is set to a supported method) | |
- `ALEXANDRIA_ENABLE_AT_REST_ENCRYPTION`: Set to `true` to enable at-rest encryption of files (enabling this causes an error unless `ALEXANDRIA_ENCRYPTRION_METHOD` is set to a supported method) |
LGTM now. Are you gonna cleanup the commits a bit before merging? Seems like quite a long chain of fixes... |
847c793
to
6ec30c2
Compare
Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.40 to 3.1.41. - [Release notes](https://github.com/gitpython-developers/GitPython/releases) - [Changelog](https://github.com/gitpython-developers/GitPython/blob/main/CHANGES) - [Commits](gitpython-developers/GitPython@3.1.40...3.1.41) --- updated-dependencies: - dependency-name: gitpython dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
enable cleanup for storage attribute add checks to prevent misconfigured usage complete coverage configure containers to allow ssec in dev env add encryption management command test finalize encryption management command
6ec30c2
to
43c220e
Compare
4e313ca
to
4f39f90
Compare
trying to merge the commits messed with the history, because there are merges in between. |
add django-storages with s3 (boto3-backed)
change file model:
content
storage-client
method (upload_url, download_url etc)setup s3 backend configuration for file upload and encryption
File.encryption_status
add view-action for file-fetching via backend
100% coverage
fix all tests
provide a presigned download url for unauthenticated file retrieval
manage command for fetching unencrypted files and reupload encrypted
per object encryption based on object name and secret