-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! fixup! fixup! add support for mongodb Client Side Field Level …
…Encryption (CSFLE)
- Loading branch information
Showing
4 changed files
with
70 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import base64 | ||
import os | ||
import random | ||
|
||
from contextlib import contextmanager | ||
|
||
|
||
@contextmanager | ||
def push_seed(seed): | ||
rstate = random.getstate() | ||
random.seed(seed) | ||
try: | ||
yield | ||
finally: | ||
random.setstate(rstate) | ||
|
||
|
||
class MingTestHelpers: | ||
|
||
@staticmethod | ||
def make_encryption_key(seed=__name__): | ||
with push_seed(seed): | ||
return base64.b64encode(os.urandom(96)).decode('ascii') | ||
|
||
KEY_VAULT_NAMESPACE = 'encryption_test.coll_key_vault_test' | ||
LOCAL_KEY = make_encryption_key('default local key') | ||
|
||
@classmethod | ||
def get_encrypt_cfg_local(cls, | ||
dbname: str, | ||
encryption_key = LOCAL_KEY, | ||
key_vault_namespace: str = KEY_VAULT_NAMESPACE): | ||
return { | ||
f'ming.{dbname}.encryption.kms_providers.local.key': encryption_key, | ||
f'ming.{dbname}.encryption.key_vault_namespace': key_vault_namespace, | ||
f'ming.{dbname}.encryption.provider_options.local.key_alt_names': '["datakeyName"]', | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters