如何防止用户能够查看其他数据库和其他数据库中的表? [英] How to prevent a user from being able to see other databases and the tables from other databases?

查看:374
本文介绍了如何防止用户能够查看其他数据库和其他数据库中的表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个postgres用户,该用户只能访问postgres服务器上的一个数据库。

I want to create a postgres user that can access only one database on the postgres server at all.

当前我的流程是:

create database database1;
create user user1 with password 'pass';
grant all privileges on database database1 to user1;

但是user1仍然可以看到数据库,用户,表等的列表。有没有一种方法可以防止该用户看到该信息?用户需要能够读写该数据库。

but user1 can still see a list of dbs, users, tables etc. Is there a way to prevent that user from seeing that info? The user needs to be able to write to and read from that db.

非常感谢。

推荐答案

每个用户都可以看到列出的其他数据库和角色,但永远不能看到其他数据库中的表。

Each user can see other databases and roles listed, but should not be able to see tables in other databases, ever.

如果撤消除分配的数据库外的所有数据库的CONNECT特权,用户将无法访问其他数据库的内容。

If you revoke CONNECT privilege on all databases except the allotted one, the user will not be able to access the contents of other databases.

角色和数据库名称是全局的,并不容易可封锁的。您可以尝试在系统表上进行选择性吊销的Frank Heikens建议,但您要冒险这样做。 Usenet邮件列表上的PostgreSQL开发人员不鼓励篡改对系统目录的访问。

Roles and database names are global, and not readily blockable. You can try Frank Heikens suggestion of selective revocations on the system tables, but you take risks to do that. PostgreSQL developers on the usenet mailing lists have discouraged tampering with access to the system catalogs.

Psql以及其他工具都假定它们将可用,并且如果没有它们,其功能将很差。

Psql, among other tools, assumes they will be available and functions poorly without them.

为什么知道其他数据库的名称和角色如此糟糕?

Why is knowing the names of other databases and roles so bad?

这篇关于如何防止用户能够查看其他数据库和其他数据库中的表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆