From: Tom Lane <tgl@sss.pgh.pa.us>
To: AC Gomez <antklc@gmail.com>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Can the current session be notified and refreshed with a new credentials context?
Date: Mon, 22 Jun 2020 21:43:21 -0400
Message-ID: <2113627.1592876601@sss.pgh.pa.us> (raw)
In-Reply-To: <CABtmK-jVokiTEFnaA27tDgF3XLmctxi3fdRt30sMmpphXG+nQA@mail.gmail.com>
References: <CABtmK-iEp48fNwHTa3PzdQyFxmDgV3c6OhzNYiOHezfaoJbHzg@mail.gmail.com>
<2094136.1592863717@sss.pgh.pa.us>
<CABtmK-g3jVU=XA0yRcoCLcdoNqXR5Fw+ZM997N-pboLm4mt-gA@mail.gmail.com>
<2094892.1592864908@sss.pgh.pa.us>
<CABtmK-jVokiTEFnaA27tDgF3XLmctxi3fdRt30sMmpphXG+nQA@mail.gmail.com>
AC Gomez <antklc@gmail.com> writes:
> OK, here goes again:
Again, you're just asserting some claims without showing us what you did.
As an example of the kind of detail I'm asking for, I ran this script
(partially based on the example in the dblink docs), starting as a
superuser so I had permissions to create everything:
-- snip --
drop database if exists mydb;
drop user if exists regress_dblink_user;
create database mydb;
\c mydb
create extension dblink;
CREATE SERVER fdtest FOREIGN DATA WRAPPER dblink_fdw OPTIONS (hostaddr '127.0.0.1', dbname 'mydb');
CREATE USER regress_dblink_user WITH PASSWORD 'secret';
CREATE USER MAPPING FOR regress_dblink_user SERVER fdtest OPTIONS (user 'regress_dblink_user', password 'secret');
GRANT USAGE ON FOREIGN SERVER fdtest TO regress_dblink_user;
\c - regress_dblink_user
create table foo (a int, b text);
insert into foo values (1, 'one'), (2, 'two');
begin;
SELECT dblink_connect('myconn', 'fdtest');
SELECT * FROM dblink('myconn', 'SELECT * FROM foo') AS t(a int, b text);
select pg_sleep(30);
SELECT * FROM dblink('myconn', 'SELECT * FROM foo') AS t(a int, b text);
commit;
-- snip --
Unsurprisingly, this worked. It also worked when I ran these commands
(in a separate session, as superuser) during the sleep:
-- snip --
\c mydb
ALTER USER regress_dblink_user WITH PASSWORD 'secret2';
ALTER USER MAPPING FOR regress_dblink_user
SERVER fdtest
OPTIONS ( SET password 'secret2');
-- snip --
And, perhaps more to the point, it *still* worked when I intentionally
mismatched the passwords in those two ALTER commands. Of course,
after that, a new dblink_connect() request failed --- but the connection
that was established before altering the password and user mapping
continued to work.
So, again: you really need to show us exactly what you are doing that
doesn't work. Because the details you've given so far do not lead
to an example that fails.
regards, tom lane
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, antklc@gmail.com
Subject: Re: Can the current session be notified and refreshed with a new credentials context?
In-Reply-To: <2113627.1592876601@sss.pgh.pa.us>
References: <CABtmK-iEp48fNwHTa3PzdQyFxmDgV3c6OhzNYiOHezfaoJbHzg@mail.gmail.com> <2094136.1592863717@sss.pgh.pa.us> <CABtmK-g3jVU=XA0yRcoCLcdoNqXR5Fw+ZM997N-pboLm4mt-gA@mail.gmail.com> <2094892.1592864908@sss.pgh.pa.us> <CABtmK-jVokiTEFnaA27tDgF3XLmctxi3fdRt30sMmpphXG+nQA@mail.gmail.com> <2113627.1592876601@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