-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Support For MongoDB Client Side Field Level Encryption (CSFLE) #67
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #67 +/- ##
==========================================
+ Coverage 90.19% 91.42% +1.22%
==========================================
Files 43 47 +4
Lines 6724 7146 +422
==========================================
+ Hits 6065 6533 +468
+ Misses 659 613 -46
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
02d4b9c
to
f2810c4
Compare
This work is not ready to merge yet as it only covers Documents. We still need to support MappedClasses. |
eaf39de
to
092d5bf
Compare
ming/datastore.py
Outdated
def encryptor(self) -> ClientEncryption: | ||
"""Creates and returns a :class:`pymongo.encryption.ClientEncryption` instance for the given ming datastore. It uses this to handle encryption/decryption using pymongo's native routines. | ||
|
||
:param ming_ds: the :class:`ming.datastore.Datastore` for which this encryptor should be configured with. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can delete this line, since self
is the datastore now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
ming/odm/property.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in def include_in_repr(self):
lets add Binary types to the skip list. I tested repr(u)
in one of the encryption tests to see what it'd look like. I don't think we want binary!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -34,7 +34,7 @@ | |||
include_package_data=True, | |||
zip_safe=True, | |||
install_requires=[ | |||
"pymongo", | |||
"pymongo[encryption]<4.9", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with this for now, to get this MR merged. But we probably should make it work on 4.9 next, before making a release 😐 In case anyone's already using ming with a higher pymongo version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
04a0b77
to
f335589
Compare
This implementation was guided largely by pymongo's examples on explicit, manual encryption.
These changes add a lot:
The
Document
class now supports automatic encryption and decryption of individual fields. It gains this ability by inheriting fromming.encryption.EncryptedDocumentMixin
and leveraging the new quasi-field classming.encryption.DecryptedField
.Encryption configuration options are handled by
ming.encryption.EncryptionConfig
ming.configure
automatically parses flattened config values like you would see in an ini. For example:A new formencode validator
ming.validators.EncryptionConfigValidator
has been added to validate config dict values.For runtime usage, the
EncryptionConfig
is added to theDataStore
instance as a newDataStore.encryption
instance property. This is what individualDocument
s reference when performing encryption/decryption.Added new package dependencies:
pymongo[decryption]
andcachetools
Added tests for new encryption features
Added new demo
docs/presentations/demo_encryption.py
See pymongo's documentation on encryption for further details on the implementation and expected configuration.