Re: Restricting user to see schema structure

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Bryn Llewellyn <bryn(at)yugabyte(dot)com>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, Neeraj M R <neerajmr12219(at)gmail(dot)com>, Tom Lane PostgreSQL <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Restricting user to see schema structure
Date: 2022-05-16 21:23:58
Message-ID: CAKFQuwbsQUzFsoY1xmS++azYx0irQR5Q6Bi5XE3a32KHLS1hfQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, May 16, 2022 at 2:04 PM Bryn Llewellyn <bryn(at)yugabyte(dot)com> wrote:

> «
> To connect to a particular database, a user must not only pass
> the pg_hba.conf checks, but must have the CONNECT privilege for the
> database. If you wish to restrict which users can connect to which
> databases, it's usually easier to control this by
> granting/revoking CONNECT privilege than to put the rules
> in pg_hba.conf entries.
> »
>
> I'd like to do what this tip says. But the regime that I have allows any
> non-super user to connect to any database.
>
> I just re-tested this with a brand-new user "joe"—and after doing "revoke
> connect on database postgres from joe".
>
> I'm obviously missing critical "pg_hba.conf" line(s). But I can't see
> what to add from the section that I mentioned. There must be some keyword,
> like "none", meaning the opposite of "all" for users.
>

You are failing to grasp the concept of "additive permissions"
(ignoring auth-method reject for now). The idea of a literal "none" makes
no sense - the absence of something is nothing, you do not say "none"
explicitly.

> But this goes against what the tip says. Anyway, after "revoke connect on
> database postgres from joe", my "\c postgres joe" succeeded.
>

See my answer, with link, from Friday. Joe's ability to connect is
inherited through PUBLIC. There is no privilege directly on Joe to revoke.

I don't quite know how to address your random experimentation with
pg_hba.conf. None of the things you showed are surprising though - were
you expecting different?

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rama Krishnan 2022-05-17 03:42:12
Previous Message Adrian Klaver 2022-05-16 21:23:48 Re: Restricting user to see schema structure