-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
152 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
:mod:`ming.encryption` module | ||
================================ | ||
|
||
|
||
.. automodule:: ming.encryption | ||
:members: | ||
:private-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
:tocdepth: 3 | ||
|
||
.. _odm-encryption: | ||
|
||
============================ | ||
Encrypting Sensitive Data | ||
============================ | ||
|
||
This section describes how Ming can be used to automatically encrypt and decrypt your document's fields. This is accomplished by leveraging MongoDB's `Client-Side Field Level Encryption (CSFLE)`_ feature. | ||
|
||
|
||
|
||
.. _Client-Side Field Level Encryption (CSFLE): https://pymongo.readthedocs.io/en/stable/examples/encryption.html#client-side-field-level-encryption | ||
|
||
|
||
Declarative Field-Level Encryption | ||
================================== | ||
|
||
When declaratively working with models by subclassing the :class:`ming.Document` in the :ref:`ming_baselevel` this is accomplished by pairing a :class:`~ming.encryption.DecryptedField` with a :class:`~ming.metadata.Field`. | ||
|
||
A simple example might look like the following.:: | ||
|
||
class UserEmail(Document): | ||
class __mongometa__: | ||
session = session | ||
name = 'user_emails' | ||
_id = Field(schema.ObjectId) | ||
|
||
email_encrypted = Field(S.Binary, if_missing=None) | ||
email = DecryptedField(str, 'email_encrypted') | ||
|
||
|
||
Breaking it Down | ||
======================== | ||
|
||
This approach requires that you follow a few conventions in order to function correctly. | ||
|
||
.. 1. Fields encrypted data must be named with the suffix `_encrypted`. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,7 @@ Documentation Content | |
polymorphism | ||
custom_properties | ||
baselevel | ||
encryption | ||
reference | ||
news | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters