Skip to content

Update qe.py #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ search/
uv.lock
docs/_build/
config/wagtail/wagtail_settings.py
HELP-72348.json
customer-master-key.txt
23 changes: 18 additions & 5 deletions qe.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
import code
import os

from bson.binary import STANDARD
from bson.codec_options import CodecOptions
from pymongo import MongoClient
from pymongo.encryption import ClientEncryption
from django_mongodb_backend.utils import get_auto_encryption_options
from django_mongodb_backend.utils import (
get_auto_encryption_opts,
get_customer_master_key,
)

HOME = os.environ.get("HOME")

kms_providers = {
"local": {
"key": get_customer_master_key(),
},
}

encrypted_client = MongoClient(
auto_encryption_opts=get_auto_encryption_options(
crypt_shared_lib_path="/Users/alexclark/Downloads/mongo_crypt_shared_v1-macos-arm64-enterprise-8.0.10/lib/mongo_crypt_v1.dylib"
auto_encryption_opts=get_auto_encryption_opts(
crypt_shared_lib_path=f"{HOME}/Downloads/mongo_crypt_shared_v1-macos-arm64-enterprise-8.0.10/lib/mongo_crypt_v1.dylib",
kms_providers=kms_providers,
)
)
kms_providers = encrypted_client.options.auto_encryption_opts._kms_providers

key_vault_namespace = encrypted_client.options.auto_encryption_opts._key_vault_namespace
codec_options = CodecOptions(uuid_representation=STANDARD)
client_encryption = ClientEncryption(
Expand All @@ -32,6 +45,6 @@
]
}
encrypted_collection = client_encryption.create_encrypted_collection(
encrypted_database, "encrypted_collection", encrypted_fields
encrypted_database, "encrypted_collection", encrypted_fields, "local"
)
code.interact(local=locals())