Skip to content

Commit ecce2ec

Browse files
authored
DRIVERS-2781 Add option to configure DEK cache lifetime (#1730)
1 parent da04aff commit ecce2ec

File tree

9 files changed

+1818
-1
lines changed

9 files changed

+1818
-1
lines changed

source/client-side-encryption/client-side-encryption.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ class AutoEncryptionOpts {
376376
// Set bypassQueryAnalysis to true to use explicit encryption on indexed fields
377377
// without the MongoDB Enterprise Advanced licensed crypt_shared library.
378378
bypassQueryAnalysis: Optional<Boolean>; // Default false.
379+
keyExpirationMS: Optional<Uint64>; // Default 60000.
379380
}
380381
```
381382

@@ -1048,6 +1049,7 @@ interface ClientEncryptionOpts {
10481049
keyVaultNamespace: String;
10491050
kmsProviders: KMSProviders;
10501051
tlsOptions?: KMSProvidersTLSOptions; // Maps KMS provider to TLS options.
1052+
keyExpirationMS: Optional<Uint64>; // Default 60000.
10511053
};
10521054

10531055
interface KMSProvidersTLSOptions {
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
runOn:
2+
- minServerVersion: "4.1.10"
3+
database_name: &database_name "default"
4+
collection_name: &collection_name "default"
5+
6+
data: []
7+
json_schema: {{schema()}}
8+
key_vault_data: [{{key()}}]
9+
10+
tests:
11+
- description: "Insert with deterministic encryption, then find it"
12+
clientOptions:
13+
autoEncryptOpts:
14+
kmsProviders:
15+
aws: {} # Credentials filled in from environment.
16+
keyExpirationMS: 1
17+
operations:
18+
- name: insertOne
19+
arguments:
20+
document: &doc0 { _id: 1, encrypted_string: "string0" }
21+
- name: wait
22+
object: testRunner
23+
arguments:
24+
ms: 2
25+
- name: find
26+
arguments:
27+
filter: { _id: 1 }
28+
result: [*doc0]
29+
expectations:
30+
# Auto encryption will request the collection info.
31+
- command_started_event:
32+
command:
33+
listCollections: 1
34+
filter:
35+
name: *collection_name
36+
command_name: listCollections
37+
# Then key is fetched from the key vault.
38+
- command_started_event:
39+
command:
40+
find: datakeys
41+
filter: {"$or": [{"_id": {"$in": [ {{key()["_id"]}} ] }}, {"keyAltNames": {"$in": []}}]}
42+
$db: keyvault
43+
readConcern: { level: "majority" }
44+
command_name: find
45+
- command_started_event:
46+
command:
47+
insert: *collection_name
48+
documents:
49+
- &doc0_encrypted { _id: 1, encrypted_string: {{ciphertext("string0", field="encrypted_string")}} }
50+
ordered: true
51+
command_name: insert
52+
- command_started_event:
53+
command:
54+
find: *collection_name
55+
filter: { _id: 1 }
56+
command_name: find
57+
# The cache has expired and the key must be fetched again
58+
- command_started_event:
59+
command:
60+
find: datakeys
61+
filter: {"$or": [{"_id": {"$in": [ {{key()["_id"]}} ] }}, {"keyAltNames": {"$in": []}}]}
62+
$db: keyvault
63+
readConcern: { level: "majority" }
64+
command_name: find
65+
outcome:
66+
collection:
67+
# Outcome is checked using a separate MongoClient without auto encryption.
68+
data:
69+
- *doc0_encrypted

source/client-side-encryption/tests/legacy/keyCache.json

Lines changed: 270 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)