Skip to content

Commit e562718

Browse files
committed
Remove get_auto_encryption_opts
1 parent a81d2ae commit e562718

File tree

3 files changed

+2
-44
lines changed

3 files changed

+2
-44
lines changed

django_mongodb_backend/encryption.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
from bson.binary import STANDARD
55
from bson.codec_options import CodecOptions
6-
from django.conf import settings
7-
from pymongo.encryption import AutoEncryptionOpts, ClientEncryption
6+
from pymongo.encryption import ClientEncryption
87

98
KEY_VAULT_COLLECTION_NAME = "__keyVault"
109
KEY_VAULT_DATABASE_NAME = "keyvault"
@@ -79,7 +78,7 @@ def allow_migrate(self, db, app_label, model_name=None, model=None, **hints):
7978
return db == "default"
8079

8180
def kms_provider(self, model):
82-
return getattr(settings, "KMS_PROVIDER", None)
81+
return "local"
8382

8483
def kms_credentials(self, model):
8584
# return KMS_CREDENTIALS.get(provider, None)
@@ -111,23 +110,6 @@ def range(cls, *, sparsity=None, precision=None, trimFactor=None):
111110
return query
112111

113112

114-
def get_auto_encryption_opts(
115-
*, key_vault_namespace, crypt_shared_lib_path=None, kms_providers=None, schema_map=None
116-
):
117-
"""
118-
Return an `AutoEncryptionOpts` instance for use with Queryable Encryption.
119-
"""
120-
# WARNING: Provide a schema map for production use. You can generate a schema map
121-
# with the management command `get_encrypted_fields_map` after adding
122-
# django_mongodb_backend to INSTALLED_APPS.
123-
return AutoEncryptionOpts(
124-
key_vault_namespace=key_vault_namespace,
125-
kms_providers=kms_providers,
126-
crypt_shared_lib_path=crypt_shared_lib_path,
127-
schema_map=schema_map,
128-
)
129-
130-
131113
def get_client_encryption(client, key_vault_namespace=None, kms_providers=None):
132114
"""
133115
Return a `ClientEncryption` instance for use with Queryable Encryption.

docs/source/howto/encryption.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,8 @@ Helper Functions and Settings
2525
``encryption.EncryptedRouter``
2626
------------------------------
2727

28-
``encryption.get_auto_encryption_opts``
29-
---------------------------------------
30-
3128
Django settings
3229
===============
3330

34-
``KMS_PROVIDER``
35-
----------------
36-
3731
DATABASES["encrypted"]["KMS_CREDENTIALS"]
3832
-----------------------------------------

tests/encryption_/tests.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
from django.db import connections
33
from django.test import TestCase, modify_settings, override_settings
44

5-
from django_mongodb_backend import encryption
6-
75
from .models import Patient, PatientRecord
86
from .routers import TestEncryptedRouter
97

@@ -43,19 +41,3 @@ def test_encrypted_fields_map(self):
4341

4442
def test_auto_encryption_opts(self):
4543
management.call_command("get_encrypted_fields_map", "--database", "encrypted", verbosity=0)
46-
47-
def test_requires_key_vault_namespace(self):
48-
with self.assertRaisesMessage(
49-
TypeError,
50-
expected_message="get_auto_encryption_opts() missing 1 required"
51-
" keyword-only argument: 'key_vault_namespace'",
52-
):
53-
encryption.get_auto_encryption_opts()
54-
55-
# @override_settings(KMS_PROVIDER=None)
56-
# def test_kms_provider_not_found(self):
57-
# with self.assertRaisesMessage(
58-
# ImproperlyConfigured,
59-
# expected_message="No KMS_PROVIDER found. Please configure KMS_PROVIDER in settings.",
60-
# ):
61-
# connections["encrypted"].schema_editor().create_model(Patient)

0 commit comments

Comments
 (0)