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 1hd20h-0000xr-1e for pgsql-general@arkaria.postgresql.org; Tue, 18 Jun 2019 00:30:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hd20f-0002yu-Oh for pgsql-general@arkaria.postgresql.org; Tue, 18 Jun 2019 00:30:01 +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 1hd20f-0002yd-Dx for pgsql-general@lists.postgresql.org; Tue, 18 Jun 2019 00:30:01 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hd20b-0004ys-NT for pgsql-general@lists.postgresql.org; Tue, 18 Jun 2019 00:30:01 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id BB6F722303; Mon, 17 Jun 2019 20:29:55 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 17 Jun 2019 20:29:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=8 RU3fe1etRroe2fdU4OIDNkVX8+bciEYfBgMGVYX60E=; b=Pg+46cbrNtbWlgnLv iwevSKKkx+WvgAutziN513DM69ArZTP9n5UkVUXhjzPYzoRgwL4QX8dsTlP04BNr QgSKtQ/fvAfaaSvrVeakrN4zqL1b50+4dwIJb68eTZfPUaSFZYsbQShR+N0Cvifr yYJWlEXeqKzT90rsZ2PjV0wkoLZci7iAyrmcnugfVNec40SLEoe+jRpLjhHjVPzS hZLCkL4cECBsA8pjGT/pNiat6CSNdzWeTD03ABmkfcGZQeWn0DqJi3Nv1aagPJCQ yiiiGHaKY7GOVtHldGXxB1G1SHOo5k0kMwJLvRe662F6g6wshJB6eqUnmuwJBYOw DG1Tg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=8RU3fe1etRroe2fdU4OIDNkVX8+bciEYfBgMGVYX6 0E=; b=rapGd4p3exeRfPWklogMZ8j0sbAbrvNba3ppNsPM8AoMB1vL6ZFqoFKFt 70REIjDQjLAdfS9ZUDTSoBwM3wx48ky4DlJxYOsLlJxtNIUJ1qKahUVQyUlL63KT pAzw49DThlcXvu06ZcwWWrPlYxv3d4sijGkrY3ufUrlIS+LNDEaH/lUMyY3ttZ8T 9W+WTW60tfKtMAd4qesODXSYtsmYxmhtlDCoJ2iz2+gxqlkzw4GaP7lZHahEGU9e YEtcHw9X74mUj/Uvas0fPlIDm6SjaHKahdMS68JYPWmVDntww3Dj3Pm52STGJG3y FDiYdGBrfwd1PQ+Co0h+DG6vbSNAQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudeikedgfeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucfkphepjedurddvuddvrdduhedtrddvtddvnecurfgrrhgrmhepmhgrihhlfhhr ohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmnecuvehluhhsth gvrhfuihiivgeptd X-ME-Proxy: Received: from [192.168.1.4] (unknown [71.212.150.202]) by mail.messagingengine.com (Postfix) with ESMTPA id E456C80060; Mon, 17 Jun 2019 20:29:54 -0400 (EDT) Subject: Re: Inserts restricted to a trigger To: Miles Elam , pgsql-general References: From: Adrian Klaver Message-ID: <6fe78cce-7e74-926b-7d3d-2e09da698cc8@aklaver.com> Date: Mon, 17 Jun 2019 17:29:54 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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) > > > Thanks in advance, > > Miles Elam -- Adrian Klaver adrian.klaver@aklaver.com