Skip to content

Commit

Permalink
Fix authentication when connecting to MongoDB (#2)
Browse files Browse the repository at this point in the history
* Fix authentication when connecting to MongoDB

* Add back travis CI for correct repository

* Fix reference to configuration file
  • Loading branch information
connorcook authored Mar 1, 2019
1 parent 66def0d commit f3f54b7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SimpleSAMLphp MongoDB Module

[![Travis build status](https://img.shields.io/travis/prolificinteractive/simplesamlphp-module-mongo.svg?style=flat-square)](https://travis-ci.org/prolificinteractive/simplesamlphp-module-mongo)
[![Travis build status](https://img.shields.io/travis/prolificinteractive/simplesamlphp-module-mongodb.svg?style=flat-square&branch=master)](https://travis-ci.org/prolificinteractive/simplesamlphp-module-mongodb)

This module is an implementation of a SimpleSAMLphp (SSP) data store to add support for the MongoDB PHP library.

Expand Down Expand Up @@ -49,7 +49,7 @@ DB_MONGODB_READ_PREFERENCE
```
See the [MongoDB extension PHP Manual](http://php.net/manual/en/set.mongodb.php) for more information about appropriate values for `DB_MONGODB_REPLICASET` and `DB_MONGODB_READ_PREFERENCE`.

Finally, you can enable the module by creating an empty file name `enable` in the `vendor/simplesamlphp/simplesamlphp/modules/mongo` directory.
Finally, you can enable the module by creating an empty file name `enable` in the `vendor/simplesamlphp/simplesamlphp/modules/mongodb` directory.

**Note:** This module stores PHP session data in the `session` collection.

Expand Down
File renamed without changes.
9 changes: 6 additions & 3 deletions lib/Store/Store.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* This file is part of the simplesamlphp-module-mongo.
* This file is part of the simplesamlphp-module-mongodb.
*
* For the full copyright and license information, please view the LICENSE file that was distributed with this source
* code.
*
* @author Chris Beaton <[email protected]>
* @package prolificinteractive/simplesamlphp-module-mongo
* @package prolificinteractive/simplesamlphp-module-mongodb
*/

use \SimpleSAML\Store;
Expand All @@ -31,7 +31,7 @@ class sspmod_mongo_Store_Store extends Store
public function __construct($connectionDetails = array())
{
$options = [];
$config = SimpleSAML_Configuration::getConfig('module_mongo.php');
$config = SimpleSAML_Configuration::getConfig('module_mongodb.php');
$connectionDetails = array_merge($config->toArray(), $connectionDetails);
if (!empty($connectionDetails['replicaSet'])) {
$options['replicaSet'] = $connectionDetails['replicaSet'];
Expand Down Expand Up @@ -61,6 +61,9 @@ static function createConnectionURI($connectionDetails = array()) {
? "${connectionDetails['username']}:${connectionDetails['password']}@"
: '')
."${seedList}";
if(!empty($connectionDetails['database'])) {
$connectionURI .= '/' . $connectionDetails['database'];
}

return $connectionURI;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Store/StoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* code.
*
* @author Chris Beaton <[email protected]>
* @package prolificinteractive/simplesamlphp-module-mongo
* @package prolificinteractive/simplesamlphp-module-mongodb
*/

namespace SimpleSAML\Test\Module\mongo\Store;
Expand Down

0 comments on commit f3f54b7

Please sign in to comment.