Skip to content

Commit 690a62a

Browse files
authored
Merge pull request #29 from aclark4life/main
Update qe.py
2 parents 3646c9f + 1f44c05 commit 690a62a

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,4 @@ search/
3131
uv.lock
3232
docs/_build/
3333
config/wagtail/wagtail_settings.py
34-
HELP-72348.json
3534
customer-master-key.txt

qe.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
11
import code
2+
import os
23

34
from bson.binary import STANDARD
45
from bson.codec_options import CodecOptions
56
from pymongo import MongoClient
67
from pymongo.encryption import ClientEncryption
7-
from django_mongodb_backend.utils import get_auto_encryption_options
8+
from django_mongodb_backend.utils import (
9+
get_auto_encryption_opts,
10+
get_customer_master_key,
11+
)
12+
13+
HOME = os.environ.get("HOME")
14+
15+
kms_providers = {
16+
"local": {
17+
"key": get_customer_master_key(),
18+
},
19+
}
820

921
encrypted_client = MongoClient(
10-
auto_encryption_opts=get_auto_encryption_options(
11-
crypt_shared_lib_path="/Users/alexclark/Downloads/mongo_crypt_shared_v1-macos-arm64-enterprise-8.0.10/lib/mongo_crypt_v1.dylib"
22+
auto_encryption_opts=get_auto_encryption_opts(
23+
crypt_shared_lib_path=f"{HOME}/Downloads/mongo_crypt_shared_v1-macos-arm64-enterprise-8.0.10/lib/mongo_crypt_v1.dylib",
24+
kms_providers=kms_providers,
1225
)
1326
)
14-
kms_providers = encrypted_client.options.auto_encryption_opts._kms_providers
27+
1528
key_vault_namespace = encrypted_client.options.auto_encryption_opts._key_vault_namespace
1629
codec_options = CodecOptions(uuid_representation=STANDARD)
1730
client_encryption = ClientEncryption(
@@ -32,6 +45,6 @@
3245
]
3346
}
3447
encrypted_collection = client_encryption.create_encrypted_collection(
35-
encrypted_database, "encrypted_collection", encrypted_fields
48+
encrypted_database, "encrypted_collection", encrypted_fields, "local"
3649
)
3750
code.interact(local=locals())

0 commit comments

Comments
 (0)