Skip to content

Commit a81d2ae

Browse files
committed
Move kms_credentials to settings
1 parent 75c3cd1 commit a81d2ae

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

django_mongodb_backend/routers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,4 @@ def register_routers():
2727
Patch the ConnectionRouter with methods to get KMS credentials and provider
2828
from the SchemaEditor.
2929
"""
30-
ConnectionRouter.kms_credentials = ConnectionRouter._router_func("kms_credentials")
3130
ConnectionRouter.kms_provider = ConnectionRouter._router_func("kms_provider")

django_mongodb_backend/schema.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from django.conf import settings
12
from django.db import router
23
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
34
from django.db.models import Index, UniqueConstraint
@@ -447,7 +448,7 @@ def _create_collection(self, model):
447448
# option is not inadvertently set to "default" somewhere
448449
# which then causes the `master_key.copy` in libmongocrypt
449450
# to fail.
450-
credentials = router.kms_credentials(model) if provider != "local" else None
451+
credentials = settings.DATABASES[db].KMS_CREDENTIALS if provider != "local" else None
451452
ce.create_encrypted_collection(
452453
db,
453454
table,

docs/source/howto/encryption.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ Django settings
3333

3434
``KMS_PROVIDER``
3535
----------------
36+
37+
DATABASES["encrypted"]["KMS_CREDENTIALS"]
38+
-----------------------------------------

0 commit comments

Comments
 (0)