pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvar Freude <alvar@a-blast.org>
Cc: Postgres General <pgsql-general@postgresql.org>
Subject: Re: Best Practices for Extensions, limitations and recommended use for monitoring
Date: Tue, 14 Aug 2018 11:07:13 -0400
Message-ID: <18652.1534259233@sss.pgh.pa.us> (raw)
In-Reply-To: <CD24F290-3747-4A2E-878F-61EB7A0A0CC2@a-blast.org>
References: <CD24F290-3747-4A2E-878F-61EB7A0A0CC2@a-blast.org>

Alvar Freude <alvar@a-blast.org> writes:
> I have a question about best practices writing PostgreSQL extensions. Is it OK to write extensions which create users and grant/revoke rights on the created functions to this users?

I'd say that's generally deprecated.  Per the documentation, you can write
CREATE USER commands in an extension script if you like, but the roles
won't be considered to "belong" to the extension, and won't be dropped
when it is.  This is mainly because roles are cluster-wide but extensions
are only local to one database.  Consider for example what will happen
when somebody tries to load your extension into more than one database in
the same cluster.

> Is it possible to add options to CREATE EXTENSION by the extension itself e.g. to make user names configurable?

No.

For the particular use-case you're describing here, maybe it'd make
sense to grant privileges to the predefined role pg_monitor, which
exists in v10 and up.  v11 has some additional predefined roles that
perhaps would fit in, too.

			regards, tom lane




view thread (3+ messages)  latest in thread

Message-ID: <18652.1534259233@sss.pgh.pa.us>
Permalink:  ../18652.1534259233@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/18652.1534259233@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, alvar@a-blast.org
  Subject: Re: Best Practices for Extensions, limitations and recommended use for monitoring
  In-Reply-To: <18652.1534259233@sss.pgh.pa.us>
  References: <CD24F290-3747-4A2E-878F-61EB7A0A0CC2@a-blast.org> <18652.1534259233@sss.pgh.pa.us>

* 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