Skip to content

The “Session Role” function is not applied to loaded layers. #62930

Description

@luziancaduff

What is the bug or the crash?

The “Session Role” function does not seem to work correctly in QGIS 3.40.6.
When editing the PostGIS connection, I can specify the session role. When I click “Test Connection” and then ‘OK’, I can see in the diagnostic tools that the command SET Role ‘xx’; is executed.

Image

However, when I then load a dataset from a schema into QGIS, a new session is created. Accordingly, the permissions of the role using the SET ROLE command are not applied.

To verify the behavior of QGIS, I analyzed the PostgreSQL logs. After closing the PostGIS connection window, QGIS executes the command SET ROLE XX as shown in the diagnostic tools. When loading a DB table, a new session with the DB is then started. The sessions all have different PIDs, which means that SET ROLE XX does not apply to subsequent sessions.

We use QGIS in conjunction with a PostgreSQL/PostGIS database (version 15.14). In pgAdmin, I can use the same commands within a session to adjust the permissions with the SET ROLE function.

Steps to reproduce the issue

  1. Set a "Session Role" in the PostGIS Connection
  2. Check if you can load a DB-table, where you should not have access to, according to the indicated session role.

Versions

QGIS-Version3.40.6-Bratislava
QGIS-Codeversion5d7f6a3e26
 
Bibliotheken
Qt-Version5.15.13
Python-Version3.12.10
GDAL-Version3.10.3
PROJ-Version9.6.0
EPSG-Registraturdatenbankversionv12.004 (2025-03-02)
GEOS-Version3.13.1-CAPI-1.19.2
SQLite-Version3.46.1
PDAL-Version2.8.3
PostgreSQL-Client-Versionunknown
SpatiaLite-Version5.1.0
QWT-Version6.3.0
QScintilla2-Version2.14.1
BS-VersionWindows 11 Version 2009
 
Aktive Python-Erweiterungen
ThurgisToolbar1.1
custom_news_feedv1.2.3
QgisModelBakerv7.11.2
lrseditor1.4.0
processing2.12.99
swiss_locator4.0.0

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response

Metadata

Metadata

Assignees

Labels

BugEither a bug report, or a bug fix. Let's hope for the latter!FeedbackWaiting on the submitter for answers

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions