-
-
Notifications
You must be signed in to change notification settings - Fork 513
Add support for Field-Level Automatic and Queryable Encryption #2759
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
base: feature/queryable-encryption
Are you sure you want to change the base?
Conversation
a6ec9ed
to
81f3e90
Compare
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.
Left some questions, and phpstan seems to be unhappy about some of the mapping types.
The logic and tests for it look solid.
<xs:element name="field" type="odm:field" minOccurs="0" maxOccurs="unbounded" /> | ||
<xs:element name="embed-one" type="odm:embed-one" minOccurs="0" maxOccurs="unbounded" /> | ||
<xs:element name="embed-many" type="odm:embed-many" minOccurs="0" maxOccurs="unbounded" /> | ||
<xs:element name="encrypt" type="odm:encrypt-field" minOccurs="0" maxOccurs="1" /> |
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.
Why is this an element instead of an attribute? Is it to future-proof this in case there will be options for encrypting entire documents in future?
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.
Yes, I plan to add a "key" attribute to the element.
$this->dm->getClientEncryption(), | ||
$this->dm->getConfiguration()->getKmsProvider(), | ||
null, // @todo when is it necessary to set the master key? | ||
$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.
Should you be using $this->getWriteOptions
here like below and add the encrypted field config?
0fc420d
to
34a9d06
Compare
'min', 'max' => match ($mapping['type']) { | ||
Type::INT => (int) $encryptValue, | ||
Type::FLOAT => (float) $encryptValue, | ||
Type::DECIMAL128 => new Decimal128((string) $encryptValue), | ||
Type::DATE, Type::DATE_IMMUTABLE => new UTCDateTime(new DateTimeImmutable((string) $encryptValue)), | ||
default => null, // Invalid | ||
}, |
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've added the transformation of values from string to native BSON types here; should use the Type::convertToDatabaseValue()
inside EncryptionFieldMap
.
Summary
Implementation:
#[Encrypt]
attribute with field encryption options.autoEncryption
configuration with options to create an encryption client (MongoDB collection that stores encryption keys for each field)The encrypted collection must be created using the schema manager (
odm:schema:create
command)