PostGIS connection to QField

Hi,
I’d like to do the direct connection to PostGIS.

What I don’t understand is the Convert to configuration? And if I check the boxes, how are the credentials saved on the android device that is using QField? My worry is how secure is this? Is the username and password of PostGIS then exposed to anyone who has the device?

Thanks


Imported from GitHub discussion by @careyshan on 2021-10-19T14:36:49Z

There is a difference if you are using plain QField or QField with QFieldCloud

But for both: You do not need to “convert to configuration”, this is for QGIS only.

QField

You have two possibilities:

  1. You need to enter the credentials and “store” in the project file. They will be stored unencrypted in the file and anyone with access can access them.
  2. You can also use a pg_service.conf file and place it on your device in a folder called QField. In this file you can define login credentials and this way not ship them with the project file.

It is not possible for a user to connect to the database without having login credentials somewhere.

QFieldCloud

As QFieldCloud will make a copy of your data, these credentials will not leave the QFieldCloud server and only the data will be sent to the device. At the moment you need to go with possibility 1. (store credentials into to project file) but possibility 2. is likely to be implemented soon.


Imported from GitHub comment by @m-kuhn on 2021-10-19T15:25:03Z

Thanks m-kuhn


Imported from GitHub comment by @careyshan on 2021-10-20T07:44:19Z

Before 2.0.10, its works by putting pg_service.conf in /storage/emulated/0/QField. But since 2.0.10, I can’t get it work.
I have tried :
/storage/emulated/0/Android/data/ch.opengis.qfield/
/storage/emulated/0/Android/data/ch.opengis.qfield/files/
/storage/emulated/0/Android/data/ch.opengis.qfield/files/QField
without success.


Imported from GitHub comment by @ldebomy on 2022-03-21T14:39:30Z

This had to be adjusted because of new Google Play policies https://www.opengis.ch/2022/03/05/qfield-users-sit-down-we-need-to-talk-about-storage-access-on-android/
It needs to be adjusted analog to
Positioning (GNSS) - QField Ecosystem Documentation

Check your about screen for the appropriate location


Imported from GitHub comment by @m-kuhn on 2022-03-21T15:54:33Z

Thank you for your answer.
My Qfield directory is /storage/emulated/0/Android/data/ch.opengis.qfield/files/QField but putting pg_service.conf in it does not work. Log shows this message : Connection to database failed definition of service “mydb” not found.


Imported from GitHub comment by @ldebomy on 2022-03-22T09:43:39Z

Idebomy , do you have a QField directory in the root of your device’s storage too by any chance?


Imported from GitHub comment by @nirvn on 2022-03-22T10:03:31Z

ldebomy , you can try APKs here, hopefully it’ll fix your issue: Test both existance and readability of the QField (root) data dir by nirvn · Pull Request #2631 · opengisch/QField · GitHub


Imported from GitHub comment by @nirvn on 2022-03-22T12:11:48Z