From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Bryn Llewellyn <bryn@yugabyte.com>
Cc: Neeraj M R <neerajmr12219@gmail.com>
Cc: Tom Lane PostgreSQL <tgl@sss.pgh.pa.us>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: Re: Restricting user to see schema structure
Date: Mon, 16 May 2022 14:23:48 -0700
Message-ID: <bb217064-ac5f-fa7e-1e66-553373f05d76@aklaver.com> (raw)
In-Reply-To: <84B060E2-4393-4D49-AB4C-BAFCA94620F1@yugabyte.com>
References: <CANV4nBEqKefjxaBJkYrucGDLM41Tr0QehG2WBmoM_D2BXTUrfg@mail.gmail.com>
<e3b4ecf7-cda2-d47b-cc0e-2b91c3b1c127@aklaver.com>
<E9B37863-A142-4898-8BD6-85D46CF2CC29@yugabyte.com>
<048ab2c5-ddf6-d039-3c2a-1828d8c9137b@aklaver.com>
<CAKFQuwYmBFKrfTstgQPSRG-gAt-2Ne=vdQOfmEUL2Sy8x5S6Cg@mail.gmail.com>
<A0348203-9026-46A0-B53E-3720EA0401F6@yugabyte.com>
<569304.1652411286@sss.pgh.pa.us>
<228E8A44-A504-4E0D-99BD-71B41812FFE2@yugabyte.com>
<CANV4nBFEVNgXy9nTwXuuRRKAY_t-LMdXFeCKVTCnXx9Z6p+P4g@mail.gmail.com>
<E92A52A6-ACA5-4CDD-B65A-624A2B335E65@yugabyte.com>
<557fd2b6-dd2e-66ad-4920-25d173eaf10e@aklaver.com>
<84B060E2-4393-4D49-AB4C-BAFCA94620F1@yugabyte.com>
On 5/16/22 2:04 PM, Bryn Llewellyn wrote:
>> /adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com> wrote:/
>>
>>> /bryn@yugabyte.com <mailto:bryn@yugabyte.com> wrote:/
>>>
>>>> /neerajmr12219@gmail.com <mailto:neerajmr12219@gmail.com> wrote:/
>>>>
>>>> ...
>>>
>>> What exactly do you mean by "have created a new user and granted
>>> connection access to database"? As I understand it, there's no such
>>> thing. I mentioned a simple test in my earlier email that showed that
>>> any user (with no schema of its own and no granted privileges) can
>>> connect to any database—and see the full metadata account of all its
>>> content. I'm teaching myself to live with this.
>>
>> Besides the REVOKE CONNECT, it is also possible to prevent connections
>> to a given database by a particular user by using settings in pg_hba.conf.
>
> Adrian, I have the "pg_hba.conf" unmodified that came with the "brew" PG
> installation of PG Version 14.2 on my MacOS Big Sur laptop. It has just
> six non-comment lines, thus:
>
> But that idea didn't work because, with my newly created user "joe", my
> "\c postgres joe" failed with a complaint that my "pg_hba.conf" had no
> entry for « user "joe", database "postgres" ».
So it worked you could not connect.
>
> I discovered (by "drop user") that « role name "none" is reserved ». So
> I added these lines:
>
> local postgres none trust
> host postgres none 127.0.0.1/32 trust
> host postgres none ::1/128 trust
none is not going to work per:
https://www.postgresql.org/docs/current/auth-pg-hba-conf.html
"user
Specifies which database user name(s) this record matches. The
value all specifies that it matches all users. Otherwise, this is either
the name of a specific database user, or a group name preceded by +.
(Recall that there is no real distinction between users and groups in
PostgreSQL; a + mark really means “match any of the roles that are
directly or indirectly members of this role”, while a name without a +
mark matches only that specific role.) For this purpose, a superuser is
only considered to be a member of a role if they are explicitly a member
of the role, directly or indirectly, and not just by virtue of being a
superuser. Multiple user names can be supplied by separating them with
commas. A separate file containing user names can be specified by
preceding the file name with @.
"
none is not listed as a special name.
> But this goes against what the tip says. Anyway, after "revoke connect
> on database postgres from joe", my "\c postgres joe" succeeded.
Because as mentioned previously you did not "revoke connect on database
postgres from public".
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, bryn@yugabyte.com, neerajmr12219@gmail.com, tgl@sss.pgh.pa.us, david.g.johnston@gmail.com
Subject: Re: Restricting user to see schema structure
In-Reply-To: <bb217064-ac5f-fa7e-1e66-553373f05d76@aklaver.com>
References: <CANV4nBEqKefjxaBJkYrucGDLM41Tr0QehG2WBmoM_D2BXTUrfg@mail.gmail.com> <e3b4ecf7-cda2-d47b-cc0e-2b91c3b1c127@aklaver.com> <E9B37863-A142-4898-8BD6-85D46CF2CC29@yugabyte.com> <048ab2c5-ddf6-d039-3c2a-1828d8c9137b@aklaver.com> <CAKFQuwYmBFKrfTstgQPSRG-gAt-2Ne=vdQOfmEUL2Sy8x5S6Cg@mail.gmail.com> <A0348203-9026-46A0-B53E-3720EA0401F6@yugabyte.com> <569304.1652411286@sss.pgh.pa.us> <228E8A44-A504-4E0D-99BD-71B41812FFE2@yugabyte.com> <CANV4nBFEVNgXy9nTwXuuRRKAY_t-LMdXFeCKVTCnXx9Z6p+P4g@mail.gmail.com> <E92A52A6-ACA5-4CDD-B65A-624A2B335E65@yugabyte.com> <557fd2b6-dd2e-66ad-4920-25d173eaf10e@aklaver.com> <84B060E2-4393-4D49-AB4C-BAFCA94620F1@yugabyte.com> <bb217064-ac5f-fa7e-1e66-553373f05d76@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox