dbeaver / cloudbeaver

Cloud Database Manager
https://dbeaver.com/
Apache License 2.0
3.52k stars 382 forks source link

Reopening a closed connection does not ask for login/password anymore #260

Closed momiji closed 3 years ago

momiji commented 3 years ago

Describe the bug

Disconnect closes the connection but does not forget associated credentials.

To Reproduce

Open a new connection for a database (like mssqlserver, but this will do the same for all), which requires credentials to be entered. Go to SQL ot whatever, and then close it (Disconnect all from menu). Then if you open again the connection, it will not ask for credentials.

Solution

I guess this is related to closeAndDeleteConnection() method that does not call webSession.removeConnection(connectionInfo);

https://github.com/dbeaver/cloudbeaver/blob/ec6eaf4899db7d28277bd4b637c32c4093d75d1e/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/impl/WebServiceCore.java#L389-L392

The fix seems to move the webSession.removeConnection(connectionInfo); out of the condition:

 if (forceDelete) { 
     webSession.getSingletonProject().getDataSourceRegistry().removeDataSource(dataSourceContainer); 
 }

 // Remove connection to forget stored credentials
 webSession.removeConnection(connectionInfo); 

Regards, Christian

kseniiaguzeeva commented 3 years ago

Can Save credentials option be enabled when you entered credentials? chrome_Tb3JYL3L5l

momiji commented 3 years ago

Not sure to understand the question here. Do you mean that "save credentials" purpouse is to keep credentials even after disconnecting all?

If so I totally didn't mis-understand it :)

kseniiaguzeeva commented 3 years ago

Yes, Save credentials option allows you to open the database without entering credentials after disconnect or re-login.

momiji commented 3 years ago

My bad... In that case does it make sens to add a new feature to forget all credentials?

kseniiaguzeeva commented 3 years ago

I see you have already created the feature request for it. It can be implemented in the future. As a workaround you can clear passwords in JSON file now.

Please ask to reopen the ticket, if you have some additional questions about it.