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 1iFtO3-0002SO-AE for pgsql-general@arkaria.postgresql.org; Thu, 03 Oct 2019 05:10:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iFtO1-0004an-52 for pgsql-general@arkaria.postgresql.org; Thu, 03 Oct 2019 05:10:45 +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 1iFtO0-0004aa-Rn for pgsql-general@lists.postgresql.org; Thu, 03 Oct 2019 05:10:44 +0000 Received: from ook.raf.org ([139.99.156.21]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iFtNy-0000r2-C6 for pgsql-general@lists.postgresql.org; Thu, 03 Oct 2019 05:10:44 +0000 Received: from localhost (localhost [127.0.0.1]) by ook.raf.org (Postfix) with ESMTP id F15415DEAB for ; Thu, 3 Oct 2019 15:10:37 +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 0ueudkRJoB-1 for ; Thu, 3 Oct 2019 15:10:37 +1000 (AEST) Received: by ook.raf.org (Postfix, from userid 1001) id A6FE85E2D8; Thu, 3 Oct 2019 15:10:37 +1000 (AEST) Date: Thu, 3 Oct 2019 15:10:37 +1000 From: raf To: pgsql-general@lists.postgresql.org Subject: Re: Users, Roles and Connection Pooling Message-ID: <20191003051037.da7na4hujcpzvi7g@raf.org> References: <0503910ff326d635e681849565de20db63c63eca.camel@cybertec.at> <20191002232708.uhg6kqz7ftob7l4n@raf.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Rob Sargent wrote: > On 10/2/19 5:27 PM, raf wrote: > > > > > I can't help with questions about scale but I like to give roles/users > > almost no permissions at all. i.e. They can't select, insert, update > > or delete anything. All they have permission to do is to execute stored > > functions that were installed by a role with the necessary permissions > > and they are security defining functions so the permissions of the role > > that created them apply when the functions are called. This means that > > there will never be any successful SQL injection, even if the application > > code is buggy, so it's more important for web applications, but I apply > > this method to internal systems as well. This approach might help with > > scaling because fewer users might be needed but I'm not sure. > > > > cheers, > > raf > > > How easy is it to introduce an new function call all the way up to the app > user? It's easy when you have the right tools to make it easy: i.e. you write the stored function, then run a tool to generate the python class for the result set and the python function that the client applications can then call to execute the stored function and return its results. > Does this approach preclude making use of any query generation > techniques available? Yes, it does. I'm happy to write my own plpgsql and sql. I find that usually results in faster results (mainly by reducing the temptation to process data outside the database) as well as being more secure. I once worked in a job were I couldn't go home until some program had finished and it was sucking data out of the database just to summarise it and insert the summaries. It tooks hours. I replaced it with a stored procedure that took two minutes and I started going home much earlier. Rightly or wrongly, that made me prefer prcessing data inside the database. cheers, raf