QGIS Project Security – How to Password Protect a QGIS Project?

passwordpostgisqgisSecurity

On a shared computer, I have a QGIS project which links up to a PostGIS database that contains my data. If a user wants to access layers from the db, they have to enter the db credentials, so that's OK.

However, I have previously logged on and imported layers from my db into QGIS, and manipulated them in QGIS (styling options based on meta-data, etc.)… Anybody who opens my QGIS project can view these layers in QGIS, and can therefore see the data I wish to be protected in my db.

Is there a way to password protect my QGIS project?

Best Answer

Your best bet is going to be not saving the db credentials in your project (QGIS even gives you a warning on the potential danger of saving your credentials when you first add the db).

When you open the project, you'll immediately be prompted for your credentials before any layers from the db are rendered.

Alternatively, you can:

  • Use OS methods to hide/protect the directory where your QGIS project is stored, ie only your user account can access that particular directory
  • You could try your hand at running a Python script on project open that might ask for credentials, though in the 5 minutes I spent trying that, could not get this to work. Check out Project Properties (CTRL+Shift+P) and then Macros to see what I mean.

To follow up on the danger of saving your db credentials in QGIS, see this question. It's trivial for anyone with the slightest curiosity to see your credentials in plain text.

Related Question