-
Notifications
You must be signed in to change notification settings - Fork 15
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
Data Administrators security group doesn't provide database access (or any access to the SRE) #1438
Comments
|
Data Administrators should have permissions to create databases in existing schemas but not to create new schemas. Can we check this? |
Some further notes on this one. The intended behaviour seems to be as follows. There is a The behaviour in Ed's point 1 is thus the intended behaviour. However, there is a bug (corrected in #1708) where no data schema is created and the relevant script for setting permissions etc isn't copied to the PostgreSQL server. This is what @jemrobinson refers to above. Ed's point 2 seems to be about a related point, but one that can't be addressed through modifying the database server itself. Instead, it seems like it would involve modifying how access to the relevant VMs is given through Guacamole, and I'm not sure whether it's best to address it or simply always give sys admins/data admins research user roles, so they can log in to the VM themselves. See also comments on #1392 |
FYI for the Pulumi rewrite we have dropped a lot of this complication by having a local admin for the databases and (potentially) giving these admin credentials to the project PI as needed. This means that data ingress would need to be done on e.g. dumps from a database that can be imported, but means that the database servers don't have special permissions that need TRE admins to carry out any actions. |
So it's great that lots of this complexity is gone with the new codebase, but still wondering how to handle this codebase. Couple more things I've come across:
This would make sense in that only superusers can modify roles, but if I'm reading this correctly, this code is by triggered by users who aren't superusers but should be. So they have to be superusers to make themselves superusers. The docs need updated to explain how all this works, too. I'm working on a PR to do this but not sure whether the intended behaviour is as above (at least whether MSSQL users should be able to do whatever they want or not). |
Excellent point that we need to focus on the existing codebase! It's certainly supposed to be the case that the MSSQL and PostgreSQL database servers behave in the same way. Are we missing a line like data-safe-haven/deployment/secure_research_environment/cloud_init/cloud-init-postgres.mustache.yaml Line 312 in fc4dc12
|
On I can't see anywhere where anything similar gets set up on the MSSQL server |
data-safe-haven/deployment/secure_research_environment/setup/Setup_SRE_Databases.ps1 Line 140 in fc4dc12
runs which sets permissions here Line 140 in fc4dc12
|
For PostgreSQL, would running a command in |
I did see that before but forgot 🤦 I'll try to figure out where it goes wrong! |
While trying to debug some of this from the command line, it seems that, currently, making a user a superuser on the postgres server also adds them locally to the system admins group, even if they should not be in that group: ![]() ![]() This means that the current trigger setup cannot remove superuser privileges from these users, as it requires them no to be in the system admins groups. This causes an issue if system admin status is removed at the SRE level (i.e. they are removed from the security group on the DC), as the remote sys admin status is ignored in favour of the database's own record of who is in the group. edit: |
Closed by #1708 |
✅ Checklist
💻 System information
🚫 Describe the problem
A user of an SRE should have the ability to create schemas in postgres via being in the
SG <SRE ID> Data Administrators
group, however there seems to be a problem with this group. At the moment, being a member of each of these groups results in the following problems:SG <SRE ID> Research Users
: can log into the TRE and connect to postgres withpsql -h PSTGRS-<SRE ID>.<SHM ID>.turingsafehaven.ac.uk -p 5432 -d postgres
, but I try to create a schema withcreate schema test;
we getERROR: permission denied for database postgres
which is what we expect. User was in both this group and the data admin group below when he got this.SG <SRE ID> Data Administrators
orSG <SRE ID> System Administrators
If a user is one of these, then they can log into the SRE first login, but not the Ubuntu login, we just get theNo recent connections
screen. I think ideally both of these access levels should allow login.When I log in as the research user and connect to the psql db and run
\du
to check the user privileges, users in theSG <SRE ID> Data Administrators
don't show up.I have tested this on multiple SREs so this is not specific to one particular instance.
Linked to #1392
🚂 Workarounds or solutions
Connected as a superuser, and edited the permissions manually
- On the PSTGRS VM (logging in via Serial Console in Azure) do
sudo -u postgres psql
- Then
GRANT CREATE ON DATABASE postgres TO "user.name";
The text was updated successfully, but these errors were encountered: