Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent a user from being able to see other databases and the tables from other databases?

Tags:

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

Currently my flow is:

create database database1; create user user1 with password 'pass'; grant all privileges on database database1 to 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.

Thanks a lot.

like image 316
Dan Avatar asked Jul 28 '10 00:07

Dan


People also ask

How do you revoke privileges in PostgreSQL?

Introduction to the PostgreSQL REVOKE statement First, specify the one or more privileges that you want to revoke. You use the ALL option to revoke all privileges. Second, specify the name of the table after the ON keyword. You use the ALL TABLES to revoke specified privileges from all tables in a schema.

What is public schema in Postgres?

Upon initial database creation, the newly created Postgresql database includes a pre-defined schema named “public”. It is a schema like any other, but the same word is also used as a keyword that denotes “all users” in contexts where otherwise an actual role name might be used, such as …


1 Answers

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

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.

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, 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?

like image 104
Rdbhost Avatar answered Nov 01 '22 13:11

Rdbhost