nextcloud / passman

🔐 Open source password manager with Nextcloud integration
https://passman.cc
GNU Affero General Public License v3.0
786 stars 108 forks source link

Passman on Nextcloud (database PostgreSQL) #434

Open ijurisic opened 6 years ago

ijurisic commented 6 years ago
## Bug report Not support PostgreSQL ### Steps to reproduce 1. When trying to add Passman to Nextcloud can't to add (if have PostgreSQL - on MySql work) ### Expected behaviour I relly love passman and hope passman will add support for PostgreSQL database. ### Actual behaviour Tell us what happens instead ### Configuration **Operating system**: Debian 9 GNU/Linux **Browser**: Waterfox **Extensions that might cause interference**: **Passman version**: **Operating system**: Debian 9 GNU/Linux **Web server:** Apache **Database:** PostgreSQL **PHP version:** 7.0 **cloud server:** Nextcloud **cloud version:** 12.0.4 #### Cloud log
Cloud log ``` {"reqId":"es9mToE2Ydvuy0BgdnPI","level":3,"time":"2018-01-19T09:15:31+00:00","remoteAddr":"192.168.4.226","user":"ivan","app":"core","method":"POST","url":"\/index.php\/settings\/ajax\/enableapp.php","message":"An exception occurred while executing 'ALTER TABLE oc_passman_share_request ALTER item_id TYPE BIGINT':\n\nSQLSTATE[42804]: Datatype mismatch: 7 ERROR: column \"item_id\" cannot be cast automatically to type bigint\nHINT: You might need to specify \"USING item_id::bigint\".","userAgent":"Mozilla\/5.0 (X11; Linux x86_64; rv:56.0) Gecko\/20100101 Firefox\/56.0.3 Waterfox\/56.0.3","version":"12.0.4.3"} ```
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/53973260-passman-on-nextcloud-database-postgresql?utm_campaign=plugin&utm_content=tracker%2F44880056&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F44880056&utm_medium=issues&utm_source=github).
synthead commented 6 years ago

This is a workaround that I've been using to use Nextcloud/Passman with PostgreSQL from this comment:

Suggested solution: PostgreSqlSchemaManager.php line 292:

    $data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM ' . $this->_platform->quoteIdentifier($sequenceName));

to:

    $version = floatval($this->_conn->getWrappedConnection()->getServerVersion());

    if ($version >= 10) {
       $data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM pg_sequences WHERE schemaname = \'public\' AND sequencename = '.$this->_conn->quote($sequenceName));
    }
    else
    {
        $data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM ' . $this->_platform->quoteIdentifier($sequenceName));
    }
ijurisic commented 6 years ago

In my case workaround not help.

{"reqId":"VBhvev1rdXhWyOj1MnLU","level":3,"time":"2018-01-26T10:50:28+00:00","remoteAddr":"192.168.4.237","user":"ivan","app":"core","method":"POST","url":"\/index.php\/settings\/ajax\/enableapp.php","message":"An exception occurred while executing 'ALTER TABLE oc_passman_share_request ALTER item_id TYPE BIGINT':\n\nSQLSTATE[42804]: Datatype mismatch: 7 ERROR: column \"item_id\" cannot be cast automatically to type bigint\nHINT: You might need to specify \"USING item_id::bigint\".","userAgent":"Mozilla\/5.0 (X11; Linux x86_64; rv:56.0) Gecko\/20100101 Firefox\/56.0.3 Waterfox\/56.0.3","version":"12.0.5.3"}

synthead commented 6 years ago

How did you generate that error?

ijurisic commented 6 years ago

Error got when hit button "Enable" in Apps->Your Apps on Passman

Screenshot https://s7.postimg.cc/wtakfpbpn/passman.png

madmath03 commented 6 years ago

That's interesting because I have been using Passman with a Nextcloud 13 using a postgres 10 for a while without any issues now... what versions of PostgreSQL are you using ?

ijurisic commented 6 years ago

PostgreSQL 9.4.15 from official Debian Jessie repository.

pierreozoux commented 3 years ago

I just got the same error, or almost the same.

I could enable/install it (maybe it throw this log, but didn't see it)

I could create a vault, but when I try to save a password, I see this error:

DriverException","Message":"An exception occurred while executing 'SELECT * FROM \"passman_credentials\" WHERE \"id\" = ?' with params [\"null\"]:\n\nSQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for type bigint: \"null\""

I guess it is related. (if it is not, then let's me know, I'll open a new issue).