Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fsVjK-0007zt-Im for pgsql-general@arkaria.postgresql.org; Wed, 22 Aug 2018 16:11:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fsVjI-0007bo-N9 for pgsql-general@arkaria.postgresql.org; Wed, 22 Aug 2018 16:11:32 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1fsVjI-0007bh-Ev for pgsql-general@lists.postgresql.org; Wed, 22 Aug 2018 16:11:32 +0000 Received: from lists.commandprompt.com ([69.168.55.30]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fsVj9-000406-A7 for pgsql-general@postgresql.org; Wed, 22 Aug 2018 16:11:31 +0000 Received: from [192.168.50.9] (spinlock.commandprompt.com [69.168.55.30]) by lists.commandprompt.com (Postfix) with ESMTPA id D9CA41A7; Wed, 22 Aug 2018 09:11:19 -0700 (PDT) Received: from c-73-97-49-9.hsd1.wa.comcast.net ([73.97.49.9] helo=[192.168.50.9]) by assp.commandprompt.com with SMTPSA(TLSv1_2 ECDHE-RSA-AES128-GCM-SHA256) (2.5.1); 22 Aug 2018 09:11:19 -0700 Subject: Re: Can Pg somehow recognize/honor linux groups to control user access ? To: David Gauthier , pgsql-general@postgresql.org References: From: "Joshua D. Drake" Organization: Command Prompt, Inc. Message-ID: <47d3c240-73ef-9b00-64d5-6c2cfb4d9b18@commandprompt.com> Date: Wed, 22 Aug 2018 09:11:19 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------2816257E6AA153A62BDA6739" Content-Language: en-US X-Assp-Version: 2.5.1(16177) on assp.commandprompt.com X-Assp-ID: assp.commandprompt.com m1-54279-11434 X-Assp-Session: 7FC7300B85E0 (mail 1) X-Assp-Original-Subject: Re: Can Pg somehow recognize/honor linux groups to control useraccess ? X-Assp-Client-SSL: yes List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------2816257E6AA153A62BDA6739 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 08/22/2018 08:56 AM, David Gauthier wrote: > Hi: > > The title says it all.  I need to be control who can gain access to a > DB based on a linux user group.  I can set up a generic role and > password, but also want to prevent users who are not in a specific > linux group from accessing the DB.  For code that works with the DB, > this is easy (just chmod the group on the code file(s)).  But is there > a way to add an additional gauntlet that checks membership in the > linux group if, for example, they were trying to get in using psql at > the linux prompt ? > > There are a couple hundred in the linux group and the list of names > changes constantly. I suppose creating a DB role per user in the linux > group may be possible if something like a cron was maintaining this > (creating/dropping uid based roles as the group membership changes) > then give everyone the same password.  But does that prevent someone > outside the linux group from just logging in with someone else's uid > and the generic password? > I'm hoping that this is a common need and that someone has a good > solution. > > Thanks in Advance for any help! You could probably write a pam module to do it but it seems to be your are inverting the problem and should be looking at this from a Postgres not Linux perspective. Perhaps consider using an SSO solution for both Linux and Postgres. JD -- Command Prompt, Inc. || http://the.postgres.company/ || @cmdpromptinc *** A fault and talent of mine is to tell it exactly how it is. *** PostgreSQL centered full stack support, consulting and development. Advocate: @amplifypostgres || Learn: https://postgresconf.org ***** Unless otherwise stated, opinions are my own. ***** --------------2816257E6AA153A62BDA6739 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 08/22/2018 08:56 AM, David Gauthier wrote:
Hi:

The title says it all.  I need to be control who can gain access to a DB based on a linux user group.  I can set up a generic role and password, but also want to prevent users who are not in a specific linux group from accessing the DB.  For code that works with the DB, this is easy (just chmod the group on the code file(s)).  But is there a way to add an additional gauntlet that checks membership in the linux group if, for example, they were trying to get in using psql at the linux prompt ?

There are a couple hundred in the linux group and the list of names changes constantly. I suppose creating a DB role per user in the linux group may be possible if something like a cron was maintaining this (creating/dropping uid based roles as the group membership changes) then give everyone the same password.  But does that prevent someone outside the linux group from just logging in with someone else's uid and the generic password?
 
I'm hoping that this is a common need and that someone has a good solution.

Thanks in Advance for any help!

You could probably write a pam module to do it but it seems to be your are inverting the problem and should be looking at this from a Postgres not Linux perspective. Perhaps consider using an SSO solution for both Linux and Postgres.

JD

-- 
Command Prompt, Inc. || http://the.postgres.company/ || @cmdpromptinc
***  A fault and talent of mine is to tell it exactly how it is.  ***
PostgreSQL centered full stack support, consulting and development. 
Advocate: @amplifypostgres || Learn: https://postgresconf.org
*****     Unless otherwise stated, opinions are my own.   *****
--------------2816257E6AA153A62BDA6739--