Skip to content

Commit 74a8905

Browse files
committed
Add documentation for stream context
1 parent 7644afb commit 74a8905

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

Resources/doc/config.rst

+59
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,63 @@ Otherwise you will get a *auth failed* exception.
431431
</doctrine:mongodb>
432432
</container>
433433
434+
Specifying a context service
435+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
436+
437+
The MongoDB driver supports receiving a stream context to set SSL and logging
438+
options. This can be used to authenticate using SSL certificates. To do so, create a service that creates your logging context:
439+
440+
.. configuration-block::
441+
442+
.. code-block:: yaml
443+
444+
services:
445+
# ...
446+
447+
app.mongodb.context_service:
448+
class: 'resource'
449+
factory: 'stream_context_create'
450+
arguments:
451+
- { ssl: { verify_expiry: true } }
452+
453+
Note: the ``class`` option is not used when creating the service, but has to be
454+
provided for the service definition to be valid.
455+
456+
You can then use this service in your configuration:
457+
458+
.. configuration-block::
459+
460+
.. code-block:: yaml
461+
462+
doctrine_mongodb:
463+
# ...
464+
connections:
465+
default:
466+
server: "mongodb://localhost:27017"
467+
driver_options:
468+
context: "app.mongodb.context_service"
469+
470+
.. code-block:: xml
471+
472+
<?xml version="1.0" ?>
473+
474+
<container xmlns="http://symfony.com/schema/dic/services"
475+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
476+
xmlns:doctrine="http://symfony.com/schema/dic/doctrine/odm/mongodb"
477+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
478+
http://symfony.com/schema/dic/doctrine/odm/mongodb http://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">
479+
480+
<doctrine:mongodb>
481+
<doctrine:connection id="default" server="mongodb://localhost:27017"/>
482+
<doctrine:driverOptions
483+
context="app.mongodb.context_service"
484+
>
485+
</doctrine:options>
486+
</doctrine:connection>
487+
</doctrine:mongodb>
488+
</container>
489+
490+
434491
Retrying Connections and Queries
435492
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
436493

@@ -501,6 +558,8 @@ Full Default Configuration
501558
username: ~
502559
w: ~
503560
wTimeoutMS: ~
561+
driver_options:
562+
context: ~ # stream context to use for connection
504563
505564
proxy_namespace: MongoDBODMProxies
506565
proxy_dir: "%kernel.cache_dir%/doctrine/odm/mongodb/Proxies"

0 commit comments

Comments
 (0)