Skip to content

Commit

Permalink
Use preexisting config for bolt
Browse files Browse the repository at this point in the history
Use of existing connection data when creating driver for bolt instead of creating a new one from scratch.
  • Loading branch information
jaltez committed Jul 1, 2020
1 parent 7203f7a commit a625877
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Connection/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ private function buildDriver()
if (preg_match('/bolt/', $this->uri)) {
$port = isset($params['port']) ? (int) $params['port'] : BoltDriver::DEFAULT_TCP_PORT;
$uri = sprintf('%s://%s:%d', $params['scheme'], $params['host'], $port);
$config = null;
$config = $this->config ? $this->config : BoltConfiguration::create();
if (isset($params['user']) && isset($params['pass'])) {
$config = BoltConfiguration::create()->withCredentials($params['user'], $params['pass']);
$config = $config->withCredentials($params['user'], $params['pass']);
}
$this->driver = BoltGraphDB::driver($uri, $config);
} elseif (preg_match('/http/', $this->uri)) {
Expand Down

1 comment on commit a625877

@jaltez
Copy link
Owner Author

@jaltez jaltez commented on a625877 Jul 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using URI connections like bolt://USER:PASS@ssl+HOST:24786 two thing happens:

  • ConnectionBuilder removes USER:PASS so credentials are not found and not set in BuildDriver()
  • The TLS mode is not inherited where is set with ssl+ or passing a \GraphAware\Bolt\Configuration object

This fix uses the preexisting config from ConnectionBuilder and extends it if necessary at BuildDriver()

Please sign in to comment.