Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AuthConfig of datasource gets expanded in createSqlVectorLayer #58019

Closed
2 tasks done
boardend opened this issue Jul 8, 2024 · 1 comment · Fixed by #58020
Closed
2 tasks done

AuthConfig of datasource gets expanded in createSqlVectorLayer #58019

boardend opened this issue Jul 8, 2024 · 1 comment · Fixed by #58020
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!

Comments

@boardend
Copy link
Contributor

boardend commented Jul 8, 2024

What is the bug or the crash?

When adding/updating a SQL-layer, the authentication configuration gets expanded in the createSqlVectorLayer-implementations of the database providers. This is critical as it leads to leaking the datasource password to the project file, even though the datasource is configured and used via the authentication manager.

This behavior was observed with a PostGIS database, but it seems that the following providers are affected:

Steps to reproduce the issue

  1. Create a new project and store it as a .qgs file
  2. Create a new PostgreSQL connection with the credentials stored in the authentication manager
  3. Add any table as layer
  4. Save the project
  5. Inspect the <datasource> in the .qgs file
    • The datasource is stored with authcfg 👍
  6. Right click on that table in the Browser -> "Execute SQL"
  7. Execute the generated query and add the new Layer with "Load layer"
  8. Save the project
    • The new datasource is stored with username and password 👎

Versions

Supported QGIS version

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

New profile

Additional context

NOTE: Will create a PR with expandAuthConfig set to false when creating the QgsVectorLayer in the providers listed above

@boardend boardend added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jul 8, 2024
@boardend
Copy link
Contributor Author

boardend commented Jul 8, 2024

Not sure if #58020 is the best approach, since uri() with expandAuthConfig defaulted to true is used in other functions of those QgsAbstractDatabaseProviderConnections..?

cc @m-kuhn, @elpaso

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant