3liz / lizmap-web-client

Transfer a QGIS project on a server, Lizmap is providing the web interface to browse it
https://www.lizmap.com
Mozilla Public License 2.0
254 stars 143 forks source link

Postgis Edit without credentials in the project #3361

Open TeoGoddet opened 1 year ago

TeoGoddet commented 1 year ago

Is your feature request related to a problem? Please describe

Hi, I would like to be able to edit postgis table without having the credentials in the project file my data sources are like this one : dbname='gaia_prod' host=xxxx.blek.ch port=5432 sslmode=require key='id' estimatedmetadata=true srid=2056 type=PolygonZ checkPrimaryKeyUnicity='1' table="2022"."scene" (geom)

When using those layer, the qgis client prompt the users for their credentials. Works OK QGIS server is given the credentials using env var PGUSER and PGPASSWORD. Works OK

Lizmap edit doesnt work. Impossible de se connecter sur xxx.blek.ch (mauvais host, login ou mot de passe ?) /www/lib/jelix/plugins/db/pgsql/pgsql.dbconnection.php 166

Describe the solution you'd like

Would you accept a pr to take username and password from env var if env is set but no username or password ?

The fix need to be done there : https://github.com/3liz/lizmap-web-client/blob/2932d421eacb58ff63b8d3eefed6e1201de97c3a/lizmap/modules/lizmap/classes/qgisVectorLayer.class.php#L251

Gustry commented 1 year ago

I'm not the expert in this area, but I guess so, feel free to provide a PR.

Otherwise, a PG service file is working well, it allows to provide any password in the QGS file.