1212KMS_PROVIDER = "local" # e.g., "aws", "azure", "gcp", "kmip", or "local"
1313
1414
15+ def get_auto_encryption_opts (
16+ key_vault_namespace = None , crypt_shared_lib_path = None , kms_providers = None
17+ ):
18+ """
19+ Returns an `AutoEncryptionOpts` instance for MongoDB Client-Side Field
20+ Level Encryption (CSFLE) that can be used to create an encrypted connection.
21+ """
22+ return AutoEncryptionOpts (
23+ key_vault_namespace = key_vault_namespace ,
24+ kms_providers = kms_providers ,
25+ crypt_shared_lib_path = crypt_shared_lib_path ,
26+ )
27+
28+
29+ def get_client_encryption (client , key_vault_namespace = None , kms_providers = None ):
30+ """
31+ Returns a `ClientEncryption` instance for MongoDB Client-Side Field Level
32+ Encryption (CSFLE) that can be used to create an encrypted collection.
33+ """
34+
35+ codec_options = CodecOptions (uuid_representation = STANDARD )
36+ return ClientEncryption (kms_providers , key_vault_namespace , client , codec_options )
37+
38+
1539def get_customer_master_key ():
1640 """
1741 Returns a 96-byte local master key for use with MongoDB Client-Side Field Level
@@ -32,43 +56,19 @@ def get_customer_master_key():
3256 )
3357
3458
35- def get_kms_providers ():
36- """
37- Return supported KMS providers for MongoDB Client-Side Field Level Encryption (CSFLE).
38- """
39- return {
40- "local" : {
41- "key" : get_customer_master_key (),
42- },
43- }
44-
45-
4659def get_key_vault_namespace (
4760 key_vault_database_name = KEY_VAULT_DATABASE_NAME ,
4861 key_vault_collection_name = KEY_VAULT_COLLECTION_NAME ,
4962):
5063 return f"{ key_vault_database_name } .{ key_vault_collection_name } "
5164
5265
53- def get_client_encryption (client , key_vault_namespace = None , kms_providers = None ):
54- """
55- Returns a `ClientEncryption` instance for MongoDB Client-Side Field Level
56- Encryption (CSFLE) that can be used to create an encrypted collection.
57- """
58-
59- codec_options = CodecOptions (uuid_representation = STANDARD )
60- return ClientEncryption (kms_providers , key_vault_namespace , client , codec_options )
61-
62-
63- def get_auto_encryption_opts (
64- key_vault_namespace = None , crypt_shared_lib_path = None , kms_providers = None
65- ):
66+ def get_kms_providers ():
6667 """
67- Returns an `AutoEncryptionOpts` instance for MongoDB Client-Side Field
68- Level Encryption (CSFLE) that can be used to create an encrypted connection.
68+ Return supported KMS providers for MongoDB Client-Side Field Level Encryption (CSFLE).
6969 """
70- return AutoEncryptionOpts (
71- key_vault_namespace = key_vault_namespace ,
72- kms_providers = kms_providers ,
73- crypt_shared_lib_path = crypt_shared_lib_path ,
74- )
70+ return {
71+ "local" : {
72+ "key" : get_customer_master_key () ,
73+ } ,
74+ }
0 commit comments