Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1myHVc-00023K-E4 for pgsql-sql@arkaria.postgresql.org; Fri, 17 Dec 2021 17:59:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1myHVa-0004IJ-N8 for pgsql-sql@arkaria.postgresql.org; Fri, 17 Dec 2021 17:59:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1myHVa-0004IA-EV for pgsql-sql@lists.postgresql.org; Fri, 17 Dec 2021 17:59:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1myHVU-0000oN-72 for pgsql-sql@lists.postgresql.org; Fri, 17 Dec 2021 17:59:06 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1BHHwtgF1364140; Fri, 17 Dec 2021 12:58:55 -0500 From: Tom Lane To: Thomas Kellerer cc: pgsql-sql@lists.postgresql.org Subject: Re: Pragma autonomous transactions in Postgres/ Certification based authentication in DB Links In-reply-to: References: <1355149.1639758450@sss.pgh.pa.us> Comments: In-reply-to Thomas Kellerer message dated "Fri, 17 Dec 2021 18:07:29 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1364138.1639763935.1@sss.pgh.pa.us> Date: Fri, 17 Dec 2021 12:58:55 -0500 Message-ID: <1364139.1639763935@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thomas Kellerer writes: > Tom Lane schrieb am 17.12.2021 um 17:27: >> No, that won't help. Like postgres_fdw, dblink will only let you use >> non-password auth methods if you're superuser [1][2]. The problem is >> that making use of any credentials stored in the server's filesystem >> amounts to impersonating the OS user that's running the server. It'd >> be nice to find a less confining solution, but I'm not sure what one >> would look like. > What about using a .pgpass file? Still amounts to impersonating the server (and yeah, we do prevent that if you're not superuser). It might make sense to have a superuser-owned SECURITY DEFINER function that's responsible for creating the desired connection, and could make use of the server's .pgpass credentials. As long as you restrict what that function is willing to do, and restrict who can execute it, this'd probably be adequately secure. regards, tom lane