So far I have a user called test_user
as shown in the image below, this user owns test_db
:
I want to revoke the user's privileges from another database I have, let's call it main_db
.
Revoke all on database main_db
from test_user
; why connected as a main_user, who is a member of {cloudsqlsuperuser}
.
Essentially I just want main_user
to only have access to main_db
and test_user
to only have access to test_db
.
So far I ran revoke privilege all on database gitlabhq_production from test_user
.
But it looks like I am still able to connect directly to the database main_db
with test_user
when I run psql -U test_user -d main_db -h 127.0.0.1 -W
. I expect this to through an error saying user cannot connect, I have also revoked all privileges of main_user
to test_db
but looks like I am still able to insert a row into test_table
which is in test_db
.
P.S I am using GCP Cloud SQL instance with Postgres 13.
How do I achieve this ?
UPDATE
Info related to the main_db, test_db and main_user and _test_user
List of roles
Role name | Attributes | Member of
---------------------------+------------------------------------------------+--------------------------------------------------------------
main_user | Create role, Create DB | {cloudsqlsuperuser}
test_user | | {}
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
---------------------+-------------------+----------+------------+------------+-----------------------------------------
main_db | main_user | UTF8 | en_US.UTF8 | en_US.UTF8 | =Tc/main_user +
| | | | | main_user=CTc/main_user
test_db | test_user | UTF8 | en_US.UTF8 | en_US.UTF8 | test_user=CTc/test_user