Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hd2Ie-0001b6-T7 for pgsql-general@arkaria.postgresql.org; Tue, 18 Jun 2019 00:48:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hd2Hf-00055u-JI for pgsql-general@arkaria.postgresql.org; Tue, 18 Jun 2019 00:47:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hd2Hf-00052C-8K for pgsql-general@lists.postgresql.org; Tue, 18 Jun 2019 00:47:35 +0000 Received: from ook.raf.org ([139.99.156.21]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hd2Hc-0005Fy-TM for pgsql-general@lists.postgresql.org; Tue, 18 Jun 2019 00:47:34 +0000 Received: from localhost (localhost [127.0.0.1]) by ook.raf.org (Postfix) with ESMTP id 621E65DE60 for ; Tue, 18 Jun 2019 10:47:28 +1000 (AEST) X-Virus-Scanned: Debian amavisd-new at ook.raf.org Received: from ook.raf.org ([127.0.0.1]) by localhost (ook.raf.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id M4-0qnXMWkiv for ; Tue, 18 Jun 2019 10:47:28 +1000 (AEST) Received: by ook.raf.org (Postfix, from userid 1001) id 1A3A55DE84; Tue, 18 Jun 2019 10:47:28 +1000 (AEST) Date: Tue, 18 Jun 2019 10:47:28 +1000 From: raf@raf.org To: pgsql-general@lists.postgresql.org Subject: Re: Inserts restricted to a trigger Message-ID: <20190618004728.ph5aeg4wlucll7y5@raf.org> References: <6fe78cce-7e74-926b-7d3d-2e09da698cc8@aklaver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6fe78cce-7e74-926b-7d3d-2e09da698cc8@aklaver.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Adrian Klaver wrote: > On 6/17/19 4:54 PM, Miles Elam wrote: > > Is there are way to restrict direct access to a table for inserts but > > allow a trigger on another table to perform an insert for that user? > > > > I'm trying to implement an audit table without allowing user tampering > > with the audit information. > > Would the below not work?: > CREATE the table as superuser or other privileged user > Have trigger function run as above user(use SECURITY DEFINER) and make sure not to give any other users insert/update/delete permissions on the audit table. > > Thanks in advance, > > > > Miles Elam > > -- > Adrian Klaver > adrian.klaver@aklaver.com