[GIS] Simplify PostGIS authentication process from QGIS

authenticationpostgisqgis

In QGIS I have a project with data from various (~15) PostGIS databases, with no login credentials (authentication user/pwd) stored for each of the connections as shown below.

enter image description here

Now when another user opens the project, he (or she) has to enter credentials for EACH database used:

enter image description here

I strongly fear that legitimatly none of my users is going to accept entering his (or her) credentials 15 times (but in an enterprise environment with potentially 100s of users, acceptance is key for success).

So two questions arise for me:

  • is there a way to suggest the Username according to the global project variable user_account_name and
  • is there a way to tell QGIS to use the credentials entered for the first db connection for any other connection as well?

I can't estimate if it would be a great deal to modify the 'Enter Credentials' dialogue as proposed below, but is this possible?

enter image description here

Best Answer

QGIS has a built-in Authentication System. Simply speaking you have a protected database with all your credentials, stored in one qgis-auth.db file, that you can send to someone else, who knows a master password:

 .qgis folder

When you create some new PostGIS connection, instead of typing your login/password you can select it from qgis-auth.db (each login/password pair has a user friendly name).

Set up PostGIS connection in QGIS with the Authentication System

As an example, I have a QGIS project which contains many layers. Each layer is a connection to a remote PostGIS database. Each database has its own user. When I open this project, I have to print a master password once, and all the layers (db connections) start to work.

I can send this project to my colleague, providing my qgis-auth.db file. Beforehand I may delete some credentials that I don't want to share from this file.

After my colleague put qgis-auth.db to his .qgis folder (he may make a backup of his own file before), he opens the project, enters the master password and everything works.

You enter a master password once per session.

Related Question