@@ -15,18 +15,15 @@ Encryption in your Django project.
1515
1616 Queryable Encryption can be used with MongoDB replica sets or sharded
1717 clusters running version 8.0 or later. Standalone instances are not
18- supported. The following table summarizes which MongoDB server products
19- support each Queryable Encryption mechanism.
20-
21- - :ref: `manual:qe-compatibility-reference `
18+ supported. The :ref: `manual:qe-compatibility-reference ` table summarizes
19+ which MongoDB server products support Queryable Encryption.
2220
2321Installation
2422============
2523
26- In addition to the :doc: `installation </intro/install >` and :doc: `configuration
27- </intro/configure>` steps required to use Django MongoDB Backend, Queryable
28- Encryption has additional dependencies. You can install these dependencies
29- by using the ``encryption `` extra when installing ``django-mongodb-backend ``:
24+ In addition to Django MongoDB Backend's regular :doc: `installation
25+ </intro/install>` and :doc: `configuration </intro/configure >` steps, Queryable
26+ Encryption has additional Python dependencies:
3027
3128.. code-block :: console
3229
@@ -49,13 +46,8 @@ configure a separate encrypted database connection in your
4946 :class: `automatic encryption
5047 <pymongo.encryption_options.AutoEncryptionOpts> `.
5148
52- The following example shows how to
53- configure an encrypted database using the :class: `AutoEncryptionOpts
54- <pymongo.encryption_options.AutoEncryptionOpts> ` from the
55- :mod: `encryption_options <pymongo.encryption_options> ` module with a local KMS
56- provider and encryption keys stored in the ``encryption.__keyVault `` collection.
57-
58- .. code-block :: python
49+ Here's how to configure an encrypted database using a local KMS provider and
50+ encryption keys stored in the ``encryption.__keyVault `` collection::
5951
6052 import os
6153
@@ -104,10 +96,7 @@ route database operations to the encrypted database.
10496
10597The following example shows how to configure a router for the "myapp"
10698application that routes database operations to the encrypted database for all
107- models in that application. The router also specifies the :ref: `KMS provider
108- <qe-configuring-kms>` to use.
109-
110- .. code-block :: python
99+ models in that application::
111100
112101 # myapp/routers.py
113102 class EncryptedRouter:
@@ -127,9 +116,7 @@ models in that application. The router also specifies the :ref:`KMS provider
127116 db_for_write = db_for_read
128117
129118Then in your Django settings, add the custom database router to the
130- :setting: `django:DATABASE_ROUTERS ` setting:
131-
132- .. code-block :: python
119+ :setting: `django:DATABASE_ROUTERS ` setting::
133120
134121 # settings.py
135122 DATABASE_ROUTERS = ["myapp.routers.EncryptedRouter"]
@@ -162,9 +149,7 @@ options followed by an example of how to use them.
162149+-------------------------------------------------------------------------+--------------------------------------------------------+
163150
164151Example of KMS configuration with ``aws `` in your :class: `kms_providers
165- <pymongo.encryption_options.AutoEncryptionOpts> ` setting:
166-
167- .. code-block :: python
152+ <pymongo.encryption_options.AutoEncryptionOpts> ` setting::
168153
169154 from pymongo.encryption_options import AutoEncryptionOpts
170155
@@ -223,12 +208,10 @@ Django MongoDB Backend, along with the entire schema, you can run the
223208
224209Use the output of :djadmin: `showencryptedfieldsmap ` to set the
225210``encrypted_fields_map `` in :class: `AutoEncryptionOpts
226- <pymongo.encryption_options.AutoEncryptionOpts> ` in your Django settings.
227-
228- .. code-block :: python
211+ <pymongo.encryption_options.AutoEncryptionOpts> ` in your Django settings::
229212
230- from pymongo.encryption_options import AutoEncryptionOpts
231213 from bson import json_util
214+ from pymongo.encryption_options import AutoEncryptionOpts
232215
233216 DATABASES = {
234217 "encrypted": {
@@ -239,30 +222,28 @@ Use the output of :djadmin:`showencryptedfieldsmap` to set the
239222 encrypted_fields_map=json_util.loads(
240223 """{
241224 "encrypt_patient": {
242- "fields": [
243- {
244- "bsonType": "string",
245- "path": "patient_record.ssn",
246- "keyId": {
247- "$binary": {
248- "base64": "2MA29LaARIOqymYHGmi2mQ==",
249- "subType": "04"
250- }
251- },
252- "queries": {
253- "queryType": "equality"
254- }
255- },
256- ]
257- }
258- }"""
225+ "fields": [
226+ {
227+ "bsonType": "string",
228+ "path": "patient_record.ssn",
229+ "keyId": {
230+ "$binary": {
231+ "base64": "2MA29LaARIOqymYHGmi2mQ==",
232+ "subType": "04"
233+ }
234+ },
235+ "queries": {
236+ "queryType": "equality"
237+ }
238+ },
239+ ]
240+ }}"""
259241 ),
260- )
242+ ),
261243 },
262244 },
263245 }
264246
265-
266247.. admonition :: Security consideration
267248
268249 Supplying an encrypted fields map provides more security than relying on an
@@ -287,9 +268,7 @@ settings using the ``crypt_shared_lib_path`` option in
287268:class: `AutoEncryptionOpts <pymongo.encryption_options.AutoEncryptionOpts> `.
288269
289270The following example shows how to configure the shared library in your Django
290- settings:
291-
292- .. code-block :: python
271+ settings::
293272
294273 from pymongo.encryption_options import AutoEncryptionOpts
295274
0 commit comments