9

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

  • so only the "Realm" is changing while all other variables stay the same? – LaughU Jul 13 '17 at 7:16
  • yes, within the real only the 'dbname' is changing. it's all on the same server. – Jochen Schwarze Jul 13 '17 at 7:26
  • maybe this post can help you: gis.stackexchange.com/questions/150623/… – LaughU Jul 13 '17 at 7:58
  • 4
    PostGIS is the spatial extension. You have over a dozen PostgreSQL databases. While you might be able to cobble together a kludge, you really ought to have one large database. Connecting to more than three is just poor application/database design. – Vince Jul 13 '17 at 10:30
  • 3
    Very heplful... Sorry that my english isn't good enough to make clear that my question is not about application/database design. And by the way, I allways thought that PostGIS implies PostgreSQL, and that in QGIS we establish PostGIS connections (cp. screenshot above). While some postgres people say that it is good practice to distribute different content in different databases where possible, please let me participate in from where you know that connecting to more than three databases is poor application design? Please, please provide the related literature reference! And why three?! – Jochen Schwarze Jul 14 '17 at 8:50
7

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.