pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Bryn Llewellyn <bryn@yugabyte.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Neeraj M R <neerajmr12219@gmail.com>
Cc: Tom Lane PostgreSQL <tgl@sss.pgh.pa.us>
Cc: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: Re: Restricting user to see schema structure
Date: Tue, 17 May 2022 08:58:28 -0700
Message-ID: <f43213da-19e2-17a1-98f0-d3ccc7699b7a@aklaver.com> (raw)
In-Reply-To: <766C91F2-6FF8-4D4B-94BB-39B3BAD2AFE8@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>
	<bb217064-ac5f-fa7e-1e66-553373f05d76@aklaver.com>
	<766C91F2-6FF8-4D4B-94BB-39B3BAD2AFE8@yugabyte.com>

On 5/16/22 22:21, Bryn Llewellyn wrote:

>> Because as mentioned previously you did not "revoke connect on 
>> database postgres from public".
> 
> Right, I see the importance of this now. I now realize that when a 
> database is created, CONNECT on it is automatically granted to PUBLIC. 
> But there's no mention of this (or what to read to learn that this is 
> the case) in the "pg_hba.conf" chapter. Nor does the section on the 
> CREATE DATABASE statement mention this. How is the neophyte supposed to 
> know about this behavior?

CREATE DATABASE is an object creation command and what you are concerned 
with is not that but the privileges associated with the object. As David 
pointed out that is spelled out in the section on privileges. To me it 
makes sense to aggregate privilege information rather then have to walk 
through all the object creation sections.

> 
> Another thing that confused me was the significance of the lines for the 
> database "replication" in the "pg_hba.conf" that came with my 
> installation. Add to this the mutually exclusive keywords "REPLICATION" 
> and "NO REPLICATION" in the CREATE ROLE statement. ("These clauses 
> determine whether a role is a replication role.") So this seems to be a 
> distinct use of the word from how it's used in "pg_hba.conf" as the name 
> of a database (that might well not exist). Strangely, the CREATE ROLE 
> doc says that you don't need either of "REPLICATION" or "NO REPLICATION" 
> but it doesn't say what the default is.


 From here:

https://www.postgresql.org/docs/current/auth-pg-hba-conf.html

"The value replication specifies that the record matches if a physical 
replication connection is requested, however, it doesn't match with 
logical replication connections. Note that physical replication 
connections do not specify any particular database whereas logical 
replication connections do specify it."

Makes sense to me, it is a 'dummy' value for binary replication 
connections as they do not actually connect to a database but to a cluster.

As to CREATE ROLE:

https://www.postgresql.org/docs/current/sql-createrole.html

REPLICATION
NOREPLICATION

"    These clauses determine whether a role is a replication role. A 
role must have this attribute (or be a superuser) in order to be able to 
connect to the server in replication mode (physical or logical 
replication) and in order to be able to create or drop replication 
slots. A role having the REPLICATION attribute is a very highly 
privileged role, and should only be used on roles actually used for 
replication. If not specified, NOREPLICATION is the default. You must be 
a superuser to create a new role having the REPLICATION attribute.
"

So the default of NOREPLICATION is mentioned.


replication(pg_hba.conf 'dummy' value) and REPLICATION/NOREPLICATION 
roles are referring to different aspects of the same process. Honestly 
I'm not seeing how this is any different from database postgres and role 
postgres.



-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (31+ messages)  latest in thread

Message-ID: <f43213da-19e2-17a1-98f0-d3ccc7699b7a@aklaver.com>
Permalink:  ../f43213da-19e2-17a1-98f0-d3ccc7699b7a@aklaver.com/
Also on:    postgresql.org/message-id/f43213da-19e2-17a1-98f0-d3ccc7699b7a@aklaver.com

 · 

reply

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, david.g.johnston@gmail.com, neerajmr12219@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: Restricting user to see schema structure
  In-Reply-To: <f43213da-19e2-17a1-98f0-d3ccc7699b7a@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> <766C91F2-6FF8-4D4B-94BB-39B3BAD2AFE8@yugabyte.com> <f43213da-19e2-17a1-98f0-d3ccc7699b7a@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