Skip to content

Admin class does not get passed credentials in DSN #60

@ollyollyollyltd

Description

@ollyollyollyltd

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions