@@ -27,6 +27,8 @@ You can install these additional dependencies with the following command::
2727
2828 pip install django-mongodb-backend[encryption]
2929
30+ .. _qe-configuring-databases-setting :
31+
3032Configuring the ``DATABASES `` setting
3133=====================================
3234
@@ -98,6 +100,8 @@ configure a custom router for Queryable Encryption:
98100
99101 DATABASE_ROUTERS = [EncryptedRouter]
100102
103+ .. _qe-configuring-kms :
104+
101105Configuring the Key Management Service (KMS)
102106============================================
103107
@@ -162,6 +166,44 @@ Example of KMS configuration with AWS KMS:
162166 Configuring the ``encrypted_fields_map ``
163167========================================
164168
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+
165207Configuring the Crypt Shared Library
166208====================================
167209
0 commit comments