-
Notifications
You must be signed in to change notification settings - Fork 269
PHPLIB-1708 Cast empty KMS provider into an object #1757
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
Conversation
1c52490
to
d96aa71
Compare
|
||
// The server requires an empty document for automatic credentials. | ||
if (isset($options['kmsProviders']) && is_array($options['kmsProviders'])) { | ||
foreach ($options['kmsProviders'] as $name => $provider) { |
Check notice
Code scanning / Psalm
MixedAssignment Note
Fixed in Doctrine MongoDB ODM Bundle by setting a DI |
@@ -37,6 +37,18 @@ public function testConstructorAutoEncryptionOpts(): void | |||
new Client(static::getUri(), [], ['autoEncryption' => $autoEncryptionOpts]); | |||
} | |||
|
|||
#[DoesNotPerformAssertions] | |||
public function testConstructorEmptyKmsProvider(): void |
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.
Would this test have failed without the above patch? If not, is anything being tested 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.
Yes:
MongoDB\Driver\Exception\EncryptionException: expected BSON document for field: gcp
Fix PHPLIB-1708
For some KMS providers, all options can be omitted. The authentication is done using the env var or the system.
https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.md#credentialproviders
The approach in doctrine/mongodb-odm#2801 is not sufficient because Symfony is not able to dump the empty object instance into the container.