-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Adding queryable encryption range support #4885
base: main
Are you sure you want to change the base?
Conversation
Supports range style queries for encrypted fields
* | ||
* @param encryptedFields can be null | ||
* @return new instance of {@link CollectionOptions}. | ||
* @since 4.5.0 |
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.
Not sure if this is the correct version?
* @param options | ||
* @return | ||
*/ | ||
public static RangeOptionsAdapter rangeOptionsAdapter(RangeOptions options) { |
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.
Only available in the 5.x driver
database.getCollection("test").drop(); | ||
|
||
ClientEncryption clientEncryption = mongoClientEncryption.getClientEncryption(); | ||
BsonDocument encryptedFields = new BsonDocument().append("fields", |
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.
Added multiple fields as:
a) its non trivial / not obvious how to do so.
b) needed to ensure testing worked as expected
|
||
private static final String LOCAL_KMS_PROVIDER = "local"; | ||
|
||
private static final Lazy<Map<String, Map<String, Object>>> LAZY_KMS_PROVIDERS = Lazy.of(() -> { |
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.
Lazily constructed the master key - so does this only once.
builder.autoEncryptionSettings(AutoEncryptionSettings.builder() // | ||
.kmsProviders(clientEncryptionSettings.getKmsProviders()) // | ||
.keyVaultNamespace(clientEncryptionSettings.getKeyVaultNamespace()) // | ||
.bypassQueryAnalysis(true).build()); |
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.
bypassQueryAnalysis
is required to be true
.
@christophstrobl apologies I closed #4879 while I was still working through it and couldn't reopen it - so created a new PR. |
Assert.isInstanceOf(Integer.class, trimFactor, () -> String | ||
.format("Expected to find a %s but it turned out to be %s.", Integer.class, trimFactor.getClass())); | ||
|
||
rangeOptionsAdapter(encryptionRangeOptions).trimFactor((Integer) trimFactor); |
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.
Not sure what the best approach is for handling Mongo driver 4 user. This adapter is needed to compile - but should there be another check to prevent them using range options at all?
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.
we're going to remove the 4.x driver backwards compatibility for the next release, so don't worry about that one.
Supports range style queries for encrypted fields.
Note: This feature requires MongoDB 8.0 and a Mongo Client 5.x