mongodb / laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)
https://www.mongodb.com/docs/drivers/php/laravel-mongodb/
MIT License
7.01k stars 1.43k forks source link

How to integrate Client side field level encryption? #2080

Closed bytewoopy closed 4 years ago

bytewoopy commented 4 years ago

I would like to enable client side field level encryption as I am using Mongo atlas with this package.

https://docs.mongodb.com/manual/core/security-client-side-encryption/#field-level-encryption-drivers

According to the php documentation I need to pass additional options "$encryptionOpts" to the connection, I am wondering how this would be possible or if anyone has done this using this package and the exposed laravel connection fields for drivers.

$encryptedClient = new Client('mongodb://127.0.0.1', [], ['autoEncryption' => $encryptionOpts]);

https://docs.mongodb.com/php-library/current/tutorial/client-side-encryption/

My current database.php settings look like this for atlas, and they work fine...but not sure how to modify to account for encryption settings.


        'mongodb_atlas' => [
            'driver'   => 'mongodb',
            'dsn' => env('DB_DSN'),
            'database' => env('DB_DATABASE'),
        ],
divine commented 4 years ago

You can provide additional options as documented here https://github.com/jenssegers/laravel-mongodb#configuration