[QGIS-Developer] [PyQGIS] adding a layer with an auth config ID leaks into the project

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[QGIS-Developer] [PyQGIS] adding a layer with an auth config ID leaks into the project

3nids
Hi all,

I add a layer using an authentification config ID using PyQGIS: 

uri = QgsDataSourceUri() 
uri.setConnection(HOST, PORT, DB, None, None, QgsDataSourceUri.SslPrefer, pg_auth_id) 

In the project, the credentials are written in clear text in the project file:

<datasource>dbname='pub' host=geodb.rootso.org port=5432 user='xxxxxx' password='xxxxxx'

Is it possible to avoid this? How?

Cheers,
Denis

_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: [PyQGIS] adding a layer with an auth config ID leaks into the project

Bernhard Ströbl
Hi Denis,

I use:
uri = QgsDataSourceUri()
uri.setDataSource(schemaName, tableName, geomColumn)
uri.setConnection(thisHostName,
     str(thisPort), thisDatabaseName,
     "", "", QgsDataSourceUri.SslRequire, thisAuthCfgId)
vLayerUri = uri.uri(False)
vlayer = QgsVectorLayer(vLayerUri, displayName, "postgres",
     layerOptions)

this works as expected storing the authcfg=auth_id using QGIS 3.4

Bernhard

Am 14.10.2019 um 15:52 schrieb Denis Rouzaud:

> Hi all,
>
> I add a layer using an authentification config ID using PyQGIS:
>
> uri = QgsDataSourceUri()
> uri.setConnection(HOST, PORT, DB, None, None,
> QgsDataSourceUri.SslPrefer, pg_auth_id)
>
> In the project, the credentials are written in clear text in the project
> file:
>
> <datasource>dbname='pub' host=geodb.rootso.org <http://geodb.rootso.org>
> port=5432 user='xxxxxx' password='xxxxxx'
>
> Is it possible to avoid this? How?
>
> Cheers,
> Denis
>


__________ Information from ESET Mail Security, version of virus signature database 20178 (20191014) __________

The message was checked by ESET Mail Security.
http://www.eset.com


_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: [PyQGIS] adding a layer with an auth config ID leaks into the project

3nids
Hi Bernard,

Many thanks works perfectly.


Le lun. 14 oct. 2019 à 16:13, Bernhard Ströbl <[hidden email]> a écrit :
Hi Denis,

I use:
uri = QgsDataSourceUri()
uri.setDataSource(schemaName, tableName, geomColumn)
uri.setConnection(thisHostName,
     str(thisPort), thisDatabaseName,
     "", "", QgsDataSourceUri.SslRequire, thisAuthCfgId)
vLayerUri = uri.uri(False)
vlayer = QgsVectorLayer(vLayerUri, displayName, "postgres",
     layerOptions)

this works as expected storing the authcfg=auth_id using QGIS 3.4

Bernhard

Am 14.10.2019 um 15:52 schrieb Denis Rouzaud:
> Hi all,
>
> I add a layer using an authentification config ID using PyQGIS:
>
> uri = QgsDataSourceUri()
> uri.setConnection(HOST, PORT, DB, None, None,
> QgsDataSourceUri.SslPrefer, pg_auth_id)
>
> In the project, the credentials are written in clear text in the project
> file:
>
> <datasource>dbname='pub' host=geodb.rootso.org <http://geodb.rootso.org>
> port=5432 user='xxxxxx' password='xxxxxx'
>
> Is it possible to avoid this? How?
>
> Cheers,
> Denis
>


__________ Information from ESET Mail Security, version of virus signature database 20178 (20191014) __________

The message was checked by ESET Mail Security.
http://www.eset.com


_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer