【发布时间】:2019-01-06 08:25:47
【问题描述】:
我在 postgres 中有两个角色,一个是 postgres,它是 super admin,另一个是 developers,它只是 create db 只能访问。
Role name | Attributes | Member of
------------+------------------------------------------------------------+-----------
developers | Create DB | {}
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
我在 developers 下创建了数据库,但是当我访问开发人员角色时,我仍然可以看到不在我下面的其他数据库。
重现步骤:
1) 以开发者身份登录
psql -U developers -d sampledb
2) 使用 \l
检查所有数据库 Name | Owner | Encoding | Collate | Ctype | Access privileges
---------------------+------------+----------+-------------+-------------+-------------------------
another_db | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres +
| | | | | postgres=CTc/postgres
developers | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres +
| | | | | postgres=CTc/postgres +
| | | | | developers=CTc/postgres
sampledb | developers | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
我应该无法访问不属于 developers 角色的其他数据库,例如 another_db 拥有的 postgres
我试图撤销访问权限
REVOKE CONNECT ON DATABASE another_db FROM developers;
REVOKE ALL PRIVILEGES ON DATABASE another_db FROM developers;
但我仍然可以将开发人员角色连接到 another_db 数据库
sampledb=> \c another_db
You are now connected to database "another_db" as user "developers".
【问题讨论】:
标签: postgresql permissions roles