@@ -27,6 +27,8 @@ You can install these additional dependencies with the following command::
27
27
28
28
pip install django-mongodb-backend[encryption]
29
29
30
+ .. _qe-configuring-databases-setting :
31
+
30
32
Configuring the ``DATABASES `` setting
31
33
=====================================
32
34
@@ -98,6 +100,8 @@ configure a custom router for Queryable Encryption:
98
100
99
101
DATABASE_ROUTERS = [EncryptedRouter]
100
102
103
+ .. _qe-configuring-kms :
104
+
101
105
Configuring the Key Management Service (KMS)
102
106
============================================
103
107
@@ -162,6 +166,44 @@ Example of KMS configuration with AWS KMS:
162
166
Configuring the ``encrypted_fields_map ``
163
167
========================================
164
168
169
+ When you :ref: `configure an encrypted database connection
170
+ <qe-configuring-databases-setting>` without specifying an
171
+ ``encrypted_fields_map `` in
172
+ :class: `pymongo.encryption_options.AutoEncryptionOpts `, Django MongoDB Backend
173
+ will create an encrypted fields map for you (when ``python manage.py migrate ``
174
+ is run), including new data keys, and use it to create collections for models
175
+ with encrypted fields.
176
+
177
+ The data keys are stored in the key vault :ref: `specified in the Django
178
+ settings <qe-configuring-kms>`. You can view the encrypted fields map by running
179
+ the :djadmin: `showencryptedfieldsmap ` command.
180
+
181
+ To see the keys created by Django MongoDB Backend in the above scenario, you can
182
+ run the following command::
183
+
184
+ python manage.py showencryptedfieldsmap --database encrypted
185
+
186
+ You can then use the output of the :djadmin: `showencryptedfieldsmap ` command
187
+ to set the ``encrypted_fields_map `` in
188
+ :class: `pymongo.encryption_options.AutoEncryptionOpts ` in your Django settings
189
+ if you want to use a pre-defined encrypted fields map in the client instead of
190
+ letting Django MongoDB Backend create them for you.
191
+
192
+ .. try to explain the chicken/egg scenario here
193
+
194
+ Of course, if you do this after Django MongoDB Backend has already created the
195
+ collections, you will need to drop the collections first before using the
196
+ pre-defined encrypted fields map.
197
+
198
+ If you do not want to use the data keys created by Django MongoDB Backend (when
199
+ ``python manage.py migrate `` is run), you can generate new data keys with::
200
+
201
+ python manage.py showencryptedfieldsmap --database encrypted \
202
+ --create-data-keys
203
+
204
+ In this scenario, Django MongoDB Backend will use the newly created data keys
205
+ to create collections for models with encrypted fields.
206
+
165
207
Configuring the Crypt Shared Library
166
208
====================================
167
209
0 commit comments