Hello,
This is probably most relevant to Ghislaine and Kriti. We have a concept of "connecting to a database" in our UI that is not quite precise.
The current UI makes it look like a Mathesar user (i.e., one that a user logs into via the Mathesar interface) connects to a given database (e.g., mathesar_tables in our default dev setup). However, what actually happens is that a given Mathesar user uses a selected database user to connect to the chosen database. This is relevant because different database users may have different permissions, and if a given Mathesar user has access to more than one database user for a given database, confusion may ensue. In fact, I suspect this exposition has already been a bit confusing.
I've spoken with a couple of devs about how to handle this, but I think most of the actual difficult problems and questions are product and UX related.
Should a Mathesar user have access to multiple DB users for the same database?
I think yes, since it may be that an admin wants to downgrade their own permissions on a given DB for daily use. Or, an admin may want to temporarily grant a Mathesar user access to a DB user with higher privileges for some task or another. It may be that some database user wants to share their DB credentials with a Mathesar user to facilitate access to some table or another. Etc.
If a Mathesar user has access to more than one DB user, how should we model that?
My instinct is to go with the tried and true brent@mydb style. I could be logged into Mathesar's UI as alice , but see brent@mydb and bob@mydb in the "connections" panel. This may be kind of irritating or confusing, however, since the access that a given Mathesar user has to a table will be dependent on which connection they're using. Our current model of tables being under schemas being under databases doesn't quite translate. Changing the user you're using to connect to the database is a different concept than changing the database entirely. For example, I'd like to be able to change the database user I'm using for connecting from within a table page when the table won't let me write, rather than navigating up to choose a new database and then back down to the table as if it were a totally separate thing.
What if they have access to more than one user on more than one DB?
Ugh. This gets ugly, and probably confusing. Design help needed.
What if we only want a Mathesar user to have a single DB user available?
We'd still need to think a bit about design for admins.
The big picture is that if we let a Mathesar user access more than one DB connection string for a given database, we need to figure out a UX concept for that and also work out the relevant design. Even if we don't want to allow that, we need some design work to help admins diagnose permissions issues without having the relevant DB user visible from the UI (with our current setup).