-
Notifications
You must be signed in to change notification settings - Fork 30
INTPYTHON-527 Add Queryable Encryption support #329
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
base: main
Are you sure you want to change the base?
Changes from 8 commits
82a3eb2
e3196e2
f23c383
7d63045
bbf38be
755cb20
51da0e9
ac265ce
175a638
106e1c7
4284529
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Settings for django_mongodb_backend/tests when encryption is supported. | ||
| import os | ||
|
|
||
| from mongodb_settings import * # noqa: F403 | ||
| from pymongo.encryption import AutoEncryptionOpts | ||
|
|
||
| os.environ["LD_LIBRARY_PATH"] = os.environ["GITHUB_WORKSPACE"] + "/lib/" | ||
|
|
||
| DATABASES["encrypted"] = { # noqa: F405 | ||
| "ENGINE": "django_mongodb_backend", | ||
| "NAME": "djangotests_encrypted", | ||
| "OPTIONS": { | ||
| "auto_encryption_opts": AutoEncryptionOpts( | ||
| key_vault_namespace="djangotests_encrypted.__keyVault", | ||
| kms_providers={"local": {"key": os.urandom(96)}}, | ||
| crypt_shared_lib_path=os.environ["GITHUB_WORKSPACE"] + "/lib/mongo_crypt_v1.so", | ||
| ), | ||
| "directConnection": True, | ||
| }, | ||
| "KMS_CREDENTIALS": {}, | ||
| } | ||
|
|
||
|
|
||
| class EncryptedRouter: | ||
| def db_for_read(self, model, **hints): | ||
| if model._meta.app_label == "encryption_": | ||
| return "encrypted" | ||
| return None | ||
|
|
||
| db_for_write = db_for_read | ||
|
|
||
| def allow_migrate(self, db, app_label, model_name=None, **hints): | ||
| # The encryption_ app's models are only created in the encrypted | ||
| # database. | ||
| if app_label == "encryption_": | ||
| return db == "encrypted" | ||
| # Don't create other app's models in the encrypted database. | ||
| if db == "encrypted": | ||
| return False | ||
| return None | ||
|
|
||
|
|
||
| DATABASE_ROUTERS.append(EncryptedRouter()) # noqa: F405 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| # Settings for django_mongodb_backend/tests. | ||
| # Settings for django_mongodb_backend/tests when encryption isn't supported. | ||
| from django_settings import * # noqa: F403 | ||
|
|
||
| DATABASES["encrypted"] = {} # noqa: F405 | ||
| DATABASE_ROUTERS = ["django_mongodb_backend.routers.MongoRouter"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ jobs: | |
| - name: install django-mongodb-backend | ||
| run: | | ||
| pip3 install --upgrade pip | ||
| pip3 install -e . | ||
| pip3 install -e .[encryption] | ||
| - name: Checkout Django | ||
| uses: actions/checkout@v5 | ||
| with: | ||
|
|
@@ -51,8 +51,14 @@ jobs: | |
| run: cp .github/workflows/runtests.py django_repo/tests/runtests_.py | ||
| - name: Start local Atlas | ||
| working-directory: . | ||
| run: bash .github/workflows/start_local_atlas.sh mongodb/mongodb-atlas-local:7 | ||
| run: bash .github/workflows/start_local_atlas.sh mongodb/mongodb-atlas-local:8.0.15 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we should have a separate job for Atlas 8 so we still test with Atlas 7, although it's useful to keep it like this for now so we can see the modifications.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we care about 7 outside of QE? If not, let's just test 8. Still thinking about going the other direction and supporting query, queryPreview, etc. But in this one case I think it's reasonable to cling to non-preview and versions that support query.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. In fact, based on the driver policy, we have to support MongoDB 6 until July 2028. I've argued that since Django 5.2 is supported until April 2028, we could make Django 5.2 the last version to support MongoDB 6. This is similar to Django's version support for its built in databases. In any case, it would be nice to finalize and document a MongoDB version support policy.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK in that case to remove as much ambiguity as possible, and to support as much MongoDB as we can, how about if we go back to 7 for QE and document |
||
| - name: Download crypt shared | ||
| run: | | ||
| wget https://downloads.mongodb.com/linux/mongo_crypt_shared_v1-linux-x86_64-enterprise-ubuntu2404-8.2.1.tgz | ||
| tar -xvzf mongo_crypt_shared_v1-linux-x86_64-enterprise-ubuntu2404-8.2.1.tgz lib/mongo_crypt_v1.so | ||
| - name: Run tests | ||
| run: python3 django_repo/tests/runtests_.py | ||
| permissions: | ||
| contents: read | ||
| env: | ||
| DJANGO_SETTINGS_MODULE: "encrypted_settings" | ||
This file was deleted.
This file was deleted.
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 would suggest just using the POC: