Bug 167960 - Base should display the authentication dialog again after a failed connection
Summary: Base should display the authentication dialog again after a failed connection
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
3.3.0 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:26.2.0
Keywords:
Depends on:
Blocks: Database
  Show dependency treegraph
 
Reported: 2025-08-15 00:41 UTC by prrvchr
Modified: 2025-08-24 12:29 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
HsqlDB LibreOffice JDBC odb file (2.17 KB, application/vnd.oasis.opendocument.database)
2025-08-17 12:17 UTC, prrvchr
Details
HsqlDB Java driver (1.59 MB, application/x-java-archive)
2025-08-17 12:18 UTC, prrvchr
Details
HsqbDB database data zip files (1.28 KB, application/zip)
2025-08-17 12:19 UTC, prrvchr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description prrvchr 2025-08-15 00:41:21 UTC
Description:
In LibreOffice if you open a Base file and connect with a different account than the one you saved and which is displayed in the authentication dialog and then close the Base file then you will be unable to reopen this Base file again without having to restart LibreOffice.



Steps to Reproduce:
You need to connect to the database with two different accounts in order to reproduce this little inconvenience. We can say user1 and user2.
Important: their password must be different...

1. Open an odb file in LibreOffice normally used by user1 but with the user2. 
2. Close this odb file.
3. Try to reopen this odb file.
4. You will never be able to

Actual Results:
If you log in with an account that is not the account saved in the odb file and after closing this file you try to reopen it, it will not be possible to log in again.

Expected Results:
When reopening a file in Base if the connection fails, then the authentication dialog should reappear.



Reproducible: Always


User Profile Reset: Yes

Additional Info:
The workaround for this problem is to close LibreOffice and reopen it...

On the other hand, if both users have the same password, then you will see that when you open the odb file for the second time, you are connected with user1 but Base keep in cache the password of user2. Unfortunately, this cannot work.
Comment 1 prrvchr 2025-08-15 00:49:48 UTC
So that there is no doubt when I say open an odb file: it is opening the file and trying to display the tables in the Base browser, in short to connect to the database.
Comment 2 prrvchr 2025-08-15 12:06:47 UTC
I haven't tried it yet, but I'm pretty sure it can be reproduced like this:

1. Open an ODB file
2. Close this ODB file.
3. Change your database password.
4. You won't be able to reopen the ODB file without restarting LibreOffice.
Comment 3 prrvchr 2025-08-15 12:11:14 UTC
At first glance I thought caching the username would be sufficient but that won't handle the case of a password change.
Comment 4 prrvchr 2025-08-17 12:17:16 UTC
Created attachment 202362 [details]
HsqlDB LibreOffice JDBC odb file
Comment 5 prrvchr 2025-08-17 12:18:41 UTC
Created attachment 202363 [details]
HsqlDB Java driver
Comment 6 prrvchr 2025-08-17 12:19:51 UTC
Created attachment 202364 [details]
HsqbDB database data zip files
Comment 7 prrvchr 2025-08-17 12:37:19 UTC
It seems difficult to reproduce with MariaDB, so I'm providing all the elements needed to reproduce this with LibreOffice's native JDBC driver and the HsqlDB database driver.

You will find three attached files:

- An odb file (file: HsqlDB LibreOffice JDBC.odb) to connect to the data file. Before any connection you will need to change the database path to the folder where you unzipped HsqlDB database data file (ie: Open the odb and go to: Edit -> Database -> Properties -> General)

- An HsqlDB database data file (file: hsqldb.data.zip) that must be unzipped into a folder. The name of this database is: db, and therefore the path to enter in the database path must end with: /db
This database has three users:
  - SA, an administrator user with no password.
  - USER: a user with no privileges (except for logging in) with the password: user
  - TEST: a user with no privileges (except for logging in) with the password: test

- The JDBC driver for the HsqlDB database (file: hsqldb.jar), which must first be added to the Java ClassPath (ie: In LibreOffice go to: Tools -> Options -> LibreOffice -> Advanced -> Class Path -> Add Archive). The class name is: org.hsqldb.jdbc.JDBCDriver
Comment 8 prrvchr 2025-08-17 15:54:18 UTC
Here's a chronological explanation of what happens when opening an ODB file in LibreOffice.

When opening a Base file for the first time, the following method will be executed:

- ODatabaseSource::connectWithCompletion: with the entered username and password.

When closing this Base file, the following method will be executed:

- ODatabaseContext::storeTransientProperties:

and the Password property will be stored.

When opening the file again, the connection will be made using the method:

- ODatasourceConnector::connect:

With the username from the ODB file and the password from the cache.

You'll never be able to go beyond this point with LibreOffice if you log in the first time with a user other than the one provided.

To fix this problem:

- I detect in ODatabaseSource::connectWithCompletion when an unknown user (other than the one in the odb file) is logged in.

- And if detected, I don't cache the password when closing in ODatabaseContext::storeTransientProperties

I haven't found anything simpler to do...
Comment 9 Commit Notification 2025-08-17 19:24:42 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/5b064206d83c6854e292e93de168fbf802201e5b

tdf#167960: store also username associated with this password

It will be available in 26.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2025-08-18 09:24:07 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/d4e478e4b501ec6c6e928fb3f3564be5f44666f4

Revert "tdf#167960: store also username associated with this password"

It will be available in 26.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2025-08-18 09:24:10 UTC
prrvchr committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/04d2a7d2f6a20bc69b7876e9c502c627e83e9f8f

tdf#167960 The password of an unknown user is no longer stored

It will be available in 26.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.