Skip to content

Commit cf730fc

Browse files
authored
CDRIVER-4365 support encryptedFields in collection create and drop (#983)
1 parent 99e9893 commit cf730fc

18 files changed

+2910
-21
lines changed

.evergreen/config.yml

Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,6 +2916,33 @@ tasks:
29162916
AUTH: noauth
29172917
SSL: nossl
29182918
VALGRIND: 'off'
2919+
- name: test-asan-latest-replica-set-auth-nosasl-openssl-cse
2920+
tags:
2921+
- client-side-encryption
2922+
- latest
2923+
- test-asan
2924+
exec_timeout_secs: 3600
2925+
depends_on:
2926+
name: debug-compile-asan-openssl-cse
2927+
commands:
2928+
- func: fetch build
2929+
vars:
2930+
BUILD_NAME: debug-compile-asan-openssl-cse
2931+
- func: bootstrap mongo-orchestration
2932+
vars:
2933+
AUTH: auth
2934+
SSL: openssl
2935+
TOPOLOGY: replica_set
2936+
VERSION: latest
2937+
- func: clone drivers-evergreen-tools
2938+
- func: run kms servers
2939+
- func: run tests
2940+
vars:
2941+
ASAN: 'on'
2942+
AUTH: auth
2943+
CLIENT_SIDE_ENCRYPTION: 'on'
2944+
SSL: openssl
2945+
VALGRIND: 'off'
29192946
- name: test-asan-latest-replica-set-auth-nosasl-openssl
29202947
tags:
29212948
- latest
@@ -5973,6 +6000,35 @@ tasks:
59736000
AUTH: noauth
59746001
SSL: nossl
59756002
VALGRIND: 'off'
6003+
- name: test-latest-replica-set-auth-sasl-openssl-cse
6004+
tags:
6005+
- auth
6006+
- client-side-encryption
6007+
- latest
6008+
- openssl
6009+
- replica_set
6010+
- sasl
6011+
depends_on:
6012+
name: debug-compile-sasl-openssl-cse
6013+
commands:
6014+
- func: fetch build
6015+
vars:
6016+
BUILD_NAME: debug-compile-sasl-openssl-cse
6017+
- func: bootstrap mongo-orchestration
6018+
vars:
6019+
AUTH: auth
6020+
SSL: openssl
6021+
TOPOLOGY: replica_set
6022+
VERSION: latest
6023+
- func: clone drivers-evergreen-tools
6024+
- func: run kms servers
6025+
- func: run tests
6026+
vars:
6027+
ASAN: 'off'
6028+
AUTH: auth
6029+
CLIENT_SIDE_ENCRYPTION: 'on'
6030+
SSL: openssl
6031+
VALGRIND: 'off'
59766032
- name: test-latest-replica-set-auth-sasl-openssl
59776033
tags:
59786034
- auth
@@ -5998,6 +6054,35 @@ tasks:
59986054
AUTH: auth
59996055
SSL: openssl
60006056
VALGRIND: 'off'
6057+
- name: test-latest-replica-set-auth-sasl-openssl-static-cse
6058+
tags:
6059+
- auth
6060+
- client-side-encryption
6061+
- latest
6062+
- openssl-static
6063+
- replica_set
6064+
- sasl
6065+
depends_on:
6066+
name: debug-compile-sasl-openssl-static-cse
6067+
commands:
6068+
- func: fetch build
6069+
vars:
6070+
BUILD_NAME: debug-compile-sasl-openssl-static-cse
6071+
- func: bootstrap mongo-orchestration
6072+
vars:
6073+
AUTH: auth
6074+
SSL: openssl-static
6075+
TOPOLOGY: replica_set
6076+
VERSION: latest
6077+
- func: clone drivers-evergreen-tools
6078+
- func: run kms servers
6079+
- func: run tests
6080+
vars:
6081+
ASAN: 'off'
6082+
AUTH: auth
6083+
CLIENT_SIDE_ENCRYPTION: 'on'
6084+
SSL: openssl-static
6085+
VALGRIND: 'off'
60016086
- name: test-latest-replica-set-auth-sasl-openssl-static
60026087
tags:
60036088
- auth
@@ -6023,6 +6108,35 @@ tasks:
60236108
AUTH: auth
60246109
SSL: openssl-static
60256110
VALGRIND: 'off'
6111+
- name: test-latest-replica-set-auth-sasl-darwinssl-cse
6112+
tags:
6113+
- auth
6114+
- client-side-encryption
6115+
- darwinssl
6116+
- latest
6117+
- replica_set
6118+
- sasl
6119+
depends_on:
6120+
name: debug-compile-sasl-darwinssl-cse
6121+
commands:
6122+
- func: fetch build
6123+
vars:
6124+
BUILD_NAME: debug-compile-sasl-darwinssl-cse
6125+
- func: bootstrap mongo-orchestration
6126+
vars:
6127+
AUTH: auth
6128+
SSL: darwinssl
6129+
TOPOLOGY: replica_set
6130+
VERSION: latest
6131+
- func: clone drivers-evergreen-tools
6132+
- func: run kms servers
6133+
- func: run tests
6134+
vars:
6135+
ASAN: 'off'
6136+
AUTH: auth
6137+
CLIENT_SIDE_ENCRYPTION: 'on'
6138+
SSL: darwinssl
6139+
VALGRIND: 'off'
60266140
- name: test-latest-replica-set-auth-sasl-darwinssl
60276141
tags:
60286142
- auth
@@ -6048,6 +6162,35 @@ tasks:
60486162
AUTH: auth
60496163
SSL: darwinssl
60506164
VALGRIND: 'off'
6165+
- name: test-latest-replica-set-auth-sasl-winssl-cse
6166+
tags:
6167+
- auth
6168+
- client-side-encryption
6169+
- latest
6170+
- replica_set
6171+
- sasl
6172+
- winssl
6173+
depends_on:
6174+
name: debug-compile-sasl-winssl-cse
6175+
commands:
6176+
- func: fetch build
6177+
vars:
6178+
BUILD_NAME: debug-compile-sasl-winssl-cse
6179+
- func: bootstrap mongo-orchestration
6180+
vars:
6181+
AUTH: auth
6182+
SSL: winssl
6183+
TOPOLOGY: replica_set
6184+
VERSION: latest
6185+
- func: clone drivers-evergreen-tools
6186+
- func: run kms servers
6187+
- func: run tests
6188+
vars:
6189+
ASAN: 'off'
6190+
AUTH: auth
6191+
CLIENT_SIDE_ENCRYPTION: 'on'
6192+
SSL: winssl
6193+
VALGRIND: 'off'
60516194
- name: test-latest-replica-set-auth-sasl-winssl
60526195
tags:
60536196
- auth
@@ -6173,6 +6316,35 @@ tasks:
61736316
AUTH: auth
61746317
SSL: winssl
61756318
VALGRIND: 'off'
6319+
- name: test-latest-replica-set-noauth-sasl-openssl-cse
6320+
tags:
6321+
- client-side-encryption
6322+
- latest
6323+
- noauth
6324+
- openssl
6325+
- replica_set
6326+
- sasl
6327+
depends_on:
6328+
name: debug-compile-sasl-openssl-cse
6329+
commands:
6330+
- func: fetch build
6331+
vars:
6332+
BUILD_NAME: debug-compile-sasl-openssl-cse
6333+
- func: bootstrap mongo-orchestration
6334+
vars:
6335+
AUTH: noauth
6336+
SSL: openssl
6337+
TOPOLOGY: replica_set
6338+
VERSION: latest
6339+
- func: clone drivers-evergreen-tools
6340+
- func: run kms servers
6341+
- func: run tests
6342+
vars:
6343+
ASAN: 'off'
6344+
AUTH: noauth
6345+
CLIENT_SIDE_ENCRYPTION: 'on'
6346+
SSL: openssl
6347+
VALGRIND: 'off'
61766348
- name: test-latest-replica-set-noauth-sasl-openssl
61776349
tags:
61786350
- latest
@@ -6198,6 +6370,35 @@ tasks:
61986370
AUTH: noauth
61996371
SSL: openssl
62006372
VALGRIND: 'off'
6373+
- name: test-latest-replica-set-noauth-sasl-openssl-static-cse
6374+
tags:
6375+
- client-side-encryption
6376+
- latest
6377+
- noauth
6378+
- openssl-static
6379+
- replica_set
6380+
- sasl
6381+
depends_on:
6382+
name: debug-compile-sasl-openssl-static-cse
6383+
commands:
6384+
- func: fetch build
6385+
vars:
6386+
BUILD_NAME: debug-compile-sasl-openssl-static-cse
6387+
- func: bootstrap mongo-orchestration
6388+
vars:
6389+
AUTH: noauth
6390+
SSL: openssl-static
6391+
TOPOLOGY: replica_set
6392+
VERSION: latest
6393+
- func: clone drivers-evergreen-tools
6394+
- func: run kms servers
6395+
- func: run tests
6396+
vars:
6397+
ASAN: 'off'
6398+
AUTH: noauth
6399+
CLIENT_SIDE_ENCRYPTION: 'on'
6400+
SSL: openssl-static
6401+
VALGRIND: 'off'
62016402
- name: test-latest-replica-set-noauth-sasl-openssl-static
62026403
tags:
62036404
- latest
@@ -6223,6 +6424,35 @@ tasks:
62236424
AUTH: noauth
62246425
SSL: openssl-static
62256426
VALGRIND: 'off'
6427+
- name: test-latest-replica-set-noauth-sasl-darwinssl-cse
6428+
tags:
6429+
- client-side-encryption
6430+
- darwinssl
6431+
- latest
6432+
- noauth
6433+
- replica_set
6434+
- sasl
6435+
depends_on:
6436+
name: debug-compile-sasl-darwinssl-cse
6437+
commands:
6438+
- func: fetch build
6439+
vars:
6440+
BUILD_NAME: debug-compile-sasl-darwinssl-cse
6441+
- func: bootstrap mongo-orchestration
6442+
vars:
6443+
AUTH: noauth
6444+
SSL: darwinssl
6445+
TOPOLOGY: replica_set
6446+
VERSION: latest
6447+
- func: clone drivers-evergreen-tools
6448+
- func: run kms servers
6449+
- func: run tests
6450+
vars:
6451+
ASAN: 'off'
6452+
AUTH: noauth
6453+
CLIENT_SIDE_ENCRYPTION: 'on'
6454+
SSL: darwinssl
6455+
VALGRIND: 'off'
62266456
- name: test-latest-replica-set-noauth-sasl-darwinssl
62276457
tags:
62286458
- darwinssl
@@ -6248,6 +6478,35 @@ tasks:
62486478
AUTH: noauth
62496479
SSL: darwinssl
62506480
VALGRIND: 'off'
6481+
- name: test-latest-replica-set-noauth-sasl-winssl-cse
6482+
tags:
6483+
- client-side-encryption
6484+
- latest
6485+
- noauth
6486+
- replica_set
6487+
- sasl
6488+
- winssl
6489+
depends_on:
6490+
name: debug-compile-sasl-winssl-cse
6491+
commands:
6492+
- func: fetch build
6493+
vars:
6494+
BUILD_NAME: debug-compile-sasl-winssl-cse
6495+
- func: bootstrap mongo-orchestration
6496+
vars:
6497+
AUTH: noauth
6498+
SSL: winssl
6499+
TOPOLOGY: replica_set
6500+
VERSION: latest
6501+
- func: clone drivers-evergreen-tools
6502+
- func: run kms servers
6503+
- func: run tests
6504+
vars:
6505+
ASAN: 'off'
6506+
AUTH: noauth
6507+
CLIENT_SIDE_ENCRYPTION: 'on'
6508+
SSL: winssl
6509+
VALGRIND: 'off'
62516510
- name: test-latest-replica-set-noauth-sasl-winssl
62526511
tags:
62536512
- latest

build/evergreen_config_lib/tasks.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,11 @@ def _check_allowed(self):
604604

605605
if self.cse:
606606
require(self.version == 'latest' or parse_version(self.version) >= parse_version("4.2"))
607-
require(self.topology == 'server')
607+
if self.version == 'latest' or parse_version(self.version) >= parse_version("6.0"):
608+
# FLE 2.0 Client-Side Encryption tasks on 6.0 require a non-standalone topology.
609+
require(self.topology in ('server', 'replica_set'))
610+
else:
611+
require(self.topology == 'server')
608612
if self.sanitizer != "asan":
609613
# limit to SASL=AUTO to reduce redundant tasks.
610614
require(self.sasl)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
:man_page: mongoc_auto_encryption_opts_set_encrypted_fields_map
2+
3+
mongoc_auto_encryption_opts_set_encrypted_fields_map()
4+
======================================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
void
12+
mongoc_auto_encryption_opts_set_encrypted_fields_map (
13+
mongoc_auto_encryption_opts_t *opts, const bson_t *encrypted_fields_map);
14+
15+
16+
Parameters
17+
----------
18+
19+
* ``opts``: The :symbol:`mongoc_auto_encryption_opts_t`
20+
* ``encrypted_fields_map``: A :symbol:`bson_t` where keys are collection namespaces and values are encrypted fields documents.
21+
22+
Supplying an ``encrypted_fields_map`` provides more security than relying on an ``encryptedFields`` obtained from the server. It protects against a malicious server advertising a false ``encryptedFields``.
23+
24+
.. seealso::
25+
26+
| :symbol:`mongoc_client_enable_auto_encryption()`
27+
28+
| The guide for :doc:`Using Client-Side Field Level Encryption <using_client_side_encryption>`
29+

src/libmongoc/doc/mongoc_auto_encryption_opts_t.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ Synopsis
3535
mongoc_auto_encryption_opts_set_bypass_auto_encryption
3636
mongoc_auto_encryption_opts_set_extra
3737
mongoc_auto_encryption_opts_set_tls_opts
38+
mongoc_auto_encryption_opts_set_encrypted_fields_map
3839

src/libmongoc/doc/mongoc_database_create_collection.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ This function creates a :symbol:`mongoc_collection_t` from the given :symbol:`mo
3030

3131
If no write concern is provided in ``opts``, the database's write concern is used.
3232

33+
The ``encryptedFields`` document in ``opts`` may be used to create a collection used for :doc:`Using Client-Side Field Level Encryption <using_client_side_encryption>`.
34+
3335
For a list of all options, see `the MongoDB Manual entry on the create command <https://docs.mongodb.org/manual/reference/command/create/>`_.
3436

3537
Errors

src/libmongoc/doc/mongoc_database_drop_with_opts.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ This function attempts to drop a database on the MongoDB server.
3030

3131
If no write concern is provided in ``opts``, the database's write concern is used.
3232

33+
The ``encryptedFields`` document in ``opts`` may be used to drop a collection used for :doc:`Using Client-Side Field Level Encryption <using_client_side_encryption>`.
34+
3335
Errors
3436
------
3537

0 commit comments

Comments
 (0)