Skip to content
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

Admin class does not get passed credentials in DSN #60

Open
ollyollyollyltd opened this issue Apr 13, 2016 · 0 comments
Open

Admin class does not get passed credentials in DSN #60

ollyollyollyltd opened this issue Apr 13, 2016 · 0 comments

Comments

@ollyollyollyltd
Copy link

The Admin class takes an (maybe) authorised client as it's first argument.

$client = new couchClient(http://username:[email protected]:5984),'myDb');
$admin = new couchAdmin($client);

When the admin class wants to make requests it uses the DSN from $client->dsn(), however the username and password is stripped from the DSN in the __construct of couch class:

// couch.php line 68
$this->dsn = preg_replace('@/+$@','',$dsn);

This means that the DSN used by the admin class will not allow the object to authenticate with the database.

At the moment I am extending the client class as so:

// MyClient.php
public function __construct($dsn, $dbname, $options = array() ) {
    parent::__construct($dsn, $dbname, $options);
    $this->dsn = $dsn;
}

This allows any admin classes to use the 'original' DSN, and thus authenticate.

Am I misunderstanding how this should be used or is this an error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant