Skip to content

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

Open
wants to merge 76 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
bc52c8e
INTPYTHON-527 Add Queryable Encryption support
aclark4life Jun 25, 2025
38fb110
Fix test for unencrypted field not in field map
aclark4life Jun 27, 2025
65bd15a
Fix test for unencrypted field not in field map
aclark4life Jun 27, 2025
e08945b
Add comment about suppressing EncryptedCollectionError
aclark4life Jun 27, 2025
7b34b44
Don't rely on features to fall back to unencrypted
aclark4life Jun 27, 2025
8e83ada
Remove _nodb_cursor and disable version check
aclark4life Jun 28, 2025
4da895c
Don't surpress encrypted error
aclark4life Jun 28, 2025
ed54a9b
Rename get_encrypted_client -> get_client_encryption
aclark4life Jun 28, 2025
8a7766c
Add encryption router
aclark4life Jun 30, 2025
eab2f2e
Add "encryption" database to encryption tests
aclark4life Jun 30, 2025
10a361e
Move encrypted_fields_map to schema (1/2)
aclark4life Jul 1, 2025
01d5485
Move encrypted_fields_map to schema (2/x)
aclark4life Jul 1, 2025
db32487
Refactor helpers
aclark4life Jul 2, 2025
b2be223
Restore get_database_version functionality
aclark4life Jul 2, 2025
27d4b8e
Move encrypted router to tests
aclark4life Jul 2, 2025
c4d1c66
Fix router tests
aclark4life Jul 2, 2025
2772aff
Test feature `supports_queryable_encryption`
aclark4life Jul 2, 2025
d2ddf4e
Add path and bsonType to _get_encrypted_fields_map
aclark4life Jul 2, 2025
e25357e
Use the right database; rename some vars
aclark4life Jul 2, 2025
6487086
Refactor helpers again
aclark4life Jul 2, 2025
bc76db3
Allow user to customize some QE settings.
aclark4life Jul 2, 2025
4dbaa8f
Allow uer to customize KMS provider.
aclark4life Jul 2, 2025
9cc5ad2
Refactor
aclark4life Jul 2, 2025
c751b2d
Alpha sort helper functions
aclark4life Jul 2, 2025
b13a07f
Fix get_database_version
aclark4life Jul 3, 2025
534da6b
A better fix for using `buildInfo` command.
aclark4life Jul 3, 2025
13578ab
Add `queries` key to encrypted fields map
aclark4life Jul 4, 2025
3342d7f
Update django_mongodb_backend/schema.py
aclark4life Jul 7, 2025
9fd21e4
Update django_mongodb_backend/schema.py
aclark4life Jul 7, 2025
9bbe741
Update tests/encryption_/models.py
aclark4life Jul 7, 2025
d1eb737
Update tests/encryption_/models.py
aclark4life Jul 7, 2025
176f016
Fix conditional
aclark4life Jul 7, 2025
264b37a
Use column instead of name
aclark4life Jul 7, 2025
1771f56
Avoid double conditional
aclark4life Jul 7, 2025
819058a
Update tests and remove test router
aclark4life Jul 7, 2025
9a3c18e
Update django_mongodb_backend/fields/encryption.py
aclark4life Jul 7, 2025
071192e
Add deconstruct method for encryption fields
aclark4life Jul 7, 2025
b2a0534
Add setup & teardown for QE features test
aclark4life Jul 7, 2025
81cc887
Add query type classes and update test
aclark4life Jul 8, 2025
be3dd16
Add missing queries to deconstruct
aclark4life Jul 8, 2025
a2342e2
Add get_encrypted_fields_map management command
aclark4life Jul 8, 2025
05a7610
Add EncryptedRouter
aclark4life Jul 8, 2025
96b3fda
Optimistically add QE to release notes :-)
aclark4life Jul 8, 2025
1eb71d5
Fix label
aclark4life Jul 8, 2025
08209d3
Save encrypted models to encrypted db
aclark4life Jul 9, 2025
90fe562
Refactor and rename QueryTypes -> QueryType
aclark4life Jul 9, 2025
8c2b84c
Refactor, reword, alpha sort, add comments.
aclark4life Jul 9, 2025
ab680fd
Alpha-sort
aclark4life Jul 9, 2025
4a267f5
Document-driven design
aclark4life Jul 9, 2025
3fdc1f7
Document-driven design
aclark4life Jul 9, 2025
d562a76
Document-driven design
aclark4life Jul 9, 2025
163758d
Add encryption.rst
aclark4life Jul 9, 2025
b95c343
Make key_vault_namespace a required kwarg
aclark4life Jul 9, 2025
5205a0b
Reuse schema editor to create encrypted fields map
aclark4life Jul 9, 2025
b07c3e6
Add --database to get_encrypted_fields_map command
aclark4life Jul 9, 2025
e557632
Add WIP configuration docs
aclark4life Jul 9, 2025
c5f8888
Add check for mongodb 7.0
aclark4life Jul 9, 2025
a7bc5c5
Let's go with "Queryable Encryption" everywhere.
aclark4life Jul 9, 2025
09423bc
Update django_mongodb_backend/fields/encryption.py
aclark4life Jul 9, 2025
c756cf8
Update tests/encryption_/tests.py
aclark4life Jul 9, 2025
841797c
Update tests/encryption_/tests.py
aclark4life Jul 9, 2025
2386397
Remove gratuitous use of with and append
aclark4life Jul 10, 2025
d685d2a
Always use `assertRaisesMessage` for > precision
aclark4life Jul 10, 2025
08ea317
only include migratable models for given database
aclark4life Jul 10, 2025
3e839d7
Refactor QueryType, add encryptino_ migration
aclark4life Jul 10, 2025
75c6936
Refactor tests and fix schema test
aclark4life Jul 10, 2025
534452f
Remove migration, already tested by schema
aclark4life Jul 10, 2025
bf26a8a
Router & schema updates
aclark4life Jul 10, 2025
bf078ad
Re-add test routers
aclark4life Jul 10, 2025
2780e32
Fix test router
aclark4life Jul 10, 2025
31d3feb
Remove ENCRYPTED_DB_ALIAS, ENCRYPTED_APPS
aclark4life Jul 10, 2025
b005726
Get rid of more settings
aclark4life Jul 10, 2025
e7290e4
Remove router allow_relation
aclark4life Jul 10, 2025
76deec0
Use class method
aclark4life Jul 10, 2025
02ce21e
Remove ENCRYPTED_DB_ALIAS
aclark4life Jul 10, 2025
c8a5118
Rename Person to Patient to match tutorial
aclark4life Jul 11, 2025
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
Prev Previous commit
Next Next commit
Fix test for unencrypted field not in field map
  • Loading branch information
aclark4life committed Jun 27, 2025
commit 65bd15a88c3dd429cef41f4fccae09d29b9da3d5
1 change: 1 addition & 0 deletions django_mongodb_backend/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def __init__(self, settings_dict, alias=DEFAULT_DB_ALIAS):
# Cache the `settings_dict` in case we need to check for
# auto_encryption_opts later.
self.__dict__["_settings_dict"] = copy.deepcopy(settings_dict)
self.encrypted_connection = None

def get_collection(self, name, **kwargs):
collection = Collection(self.database, name, **kwargs)
Expand Down
13 changes: 7 additions & 6 deletions django_mongodb_backend/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,16 +447,17 @@ def _create_collection(self, model):
auto_encryption_opts = self.connection._settings_dict.get("OPTIONS", {}).get(
"auto_encryption_opts"
)
# Use the cached settings dict to create a new connection
encrypted_connection = self.connection.get_new_connection(
self.connection._settings_dict
)
if not self.connection.encrypted_connection:
# Use the cached settings dict to create a new connection
self.encrypted_connection = self.connection.get_new_connection(
self.connection._settings_dict
)
# Use the encrypted connection and auto_encryption_opts to create an encrypted client
encrypted_client = get_encrypted_client(auto_encryption_opts, encrypted_connection)
encrypted_client = get_encrypted_client(auto_encryption_opts, self.encrypted_connection)

with contextlib.suppress(EncryptedCollectionError):
encrypted_client.create_encrypted_collection(
encrypted_connection[self.connection.database.name],
self.encrypted_connection[self.connection.database.name],
model._meta.db_table,
model.encrypted_fields_map,
"local", # TODO: KMS provider should be configurable
Expand Down