Skip to content

Commit 5604f79

Browse files
committed
Fix kms providers
1 parent d6e1425 commit 5604f79

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

django_mongodb_backend/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
# Check Django compatibility before other imports which may fail if the
44
# wrong version of Django is installed.
5-
from .utils import check_django_compatability, get_auto_encryption_opts, parse_uri
5+
from .utils import (
6+
check_django_compatability,
7+
get_auto_encryption_opts,
8+
get_kms_providers,
9+
parse_uri,
10+
)
611

712
check_django_compatability()
813

@@ -15,7 +20,7 @@
1520
from .lookups import register_lookups # noqa: E402
1621
from .query import register_nodes # noqa: E402
1722

18-
__all__ = ["get_auto_encryption_opts", "parse_uri"]
23+
__all__ = ["get_auto_encryption_opts", "get_kms_providers", "parse_uri"]
1924

2025
register_aggregates()
2126
register_checks()

django_mongodb_backend/utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ def get_customer_master_key():
6767

6868
def get_kms_providers():
6969
"""
70-
Return the KMS providers for the MongoDB client.
70+
Return supported KMS providers for MongoDB Client-Side Field Level Encryption.
7171
"""
72-
if not settings.KMS_PROVIDERS:
73-
raise ImproperlyConfigured("You must set KMS_PROVIDERS in your Django settings.")
74-
return settings.KMS_PROVIDERS
72+
return {
73+
"local": {
74+
"key": get_customer_master_key(),
75+
},
76+
}
7577

7678

7779
def parse_uri(uri, *, db_name=None, test=None, options=None):

0 commit comments

Comments
 (0)