-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
feat(NODE-6507): generate encryption configuration on mongoose connect #15320
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
feat(NODE-6507): generate encryption configuration on mongoose connect #15320
Conversation
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'd also like to see tests covering:
- Subdocuments
- Document arrays
- Maps
If you can do CSFLE with nested paths, you should be able to also do CSFLE with subdocuments, which are slightly different.
I believe I now have tests for all of these. Let me know if I'm still missing anything |
} | ||
} | ||
|
||
function* allNestedPaths(schema) { |
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.
This is a neat use case for generators, but I think doing [...Object.keys(schema.paths), ...Object.keys(schema.singleNestedPaths)] would be more concise and more consistent with the rest of the codebase
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.
Will merge into csfle branch
Summary
This PR contains the meat and potatoes of the automatic CSFLE/QE integration into mongoose. With the changes included, users can now create encrypted schemas, instantiate models with them, insert and query using their model and have the resultant documents be encrypted and decrypted automatically.
This PR contains a lot of test changes. I tried to be as exhaustive to ensure as much coverage as possible, and because the schema format is unlikely to change (changing the format of encryptedFieldsMap or schemaMap would break a lot of drivers and applications). So ideally these tests are not a large maintenance burden.
Examples
See the integration tests in
encryption.test.ts
for an example of how the API works.