Skip to content

Commit 3dca177

Browse files
committed
Remove get_client_encryption
1 parent e562718 commit 3dca177

File tree

2 files changed

+3
-20
lines changed

2 files changed

+3
-20
lines changed

django_mongodb_backend/encryption.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Queryable Encryption helpers
22
import os
33

4-
from bson.binary import STANDARD
5-
from bson.codec_options import CodecOptions
6-
from pymongo.encryption import ClientEncryption
7-
84
KEY_VAULT_COLLECTION_NAME = "__keyVault"
95
KEY_VAULT_DATABASE_NAME = "keyvault"
106
KEY_VAULT_NAMESPACE = f"{KEY_VAULT_DATABASE_NAME}.{KEY_VAULT_COLLECTION_NAME}"
@@ -108,12 +104,3 @@ def range(cls, *, sparsity=None, precision=None, trimFactor=None):
108104
if trimFactor is not None:
109105
query["trimFactor"] = trimFactor
110106
return query
111-
112-
113-
def get_client_encryption(client, key_vault_namespace=None, kms_providers=None):
114-
"""
115-
Return a `ClientEncryption` instance for use with Queryable Encryption.
116-
"""
117-
118-
codec_options = CodecOptions(uuid_representation=STANDARD)
119-
return ClientEncryption(kms_providers, key_vault_namespace, client, codec_options)

django_mongodb_backend/schema.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
from django.db import router
33
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
44
from django.db.models import Index, UniqueConstraint
5+
from pymongo.encryption import ClientEncryption, CodecOptions
56
from pymongo.operations import SearchIndexModel
67

7-
from .encryption import get_client_encryption
88
from .fields import EmbeddedModelField
99
from .indexes import SearchIndex
1010
from .query import wrap_database_errors
@@ -435,12 +435,8 @@ def _create_collection(self, model):
435435

436436
key_vault_namespace = options._key_vault_namespace
437437
kms_providers = options._kms_providers
438-
439-
ce = get_client_encryption(
440-
client,
441-
key_vault_namespace=key_vault_namespace,
442-
kms_providers=kms_providers,
443-
)
438+
codec_options = CodecOptions()
439+
ce = ClientEncryption(kms_providers, key_vault_namespace, client, codec_options)
444440
table = model._meta.db_table
445441
fields = {"fields": self._get_encrypted_fields_map(model)}
446442
provider = router.kms_provider(model)

0 commit comments

Comments
 (0)