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 1fsbfg-0001gh-DX for pgsql-general@arkaria.postgresql.org; Wed, 22 Aug 2018 22:32:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fsbfc-0004Pu-GR for pgsql-general@arkaria.postgresql.org; Wed, 22 Aug 2018 22:32:08 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fsbfc-0004Pm-2i for pgsql-general@lists.postgresql.org; Wed, 22 Aug 2018 22:32:08 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fsbfY-0005Ok-Nq for pgsql-general@postgresql.org; Wed, 22 Aug 2018 22:32:06 +0000 Received: by mail-pg1-x530.google.com with SMTP id m4-v6so1039089pgv.12 for ; Wed, 22 Aug 2018 15:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=om4cb1e9PvD/eHqzbHq7Ps5c524OGWzByLwqLp0dJ98=; b=dSuMKazQEmVw6kQwxnKEfka79/IJs/tnJLwim6tGJ4QZELCDNJKKoQuNcSYXQJVtEM Ze+DEQpuZdaE81kMvIQb7wRax3SjLsGc4VoweyqoprgEB5AdOjgcx7NjSd9m3ifEpV36 Xkd7KqE2Kipr79x1n1CzaH1g+mBgG0djrz414QEzQBD0dL14EIpUiGYFq/RpJUQa7tUu n4cDaH3CxzdNFQ48oltOSNu7bmOQhq0WXD8cKdIk6dZAWRFokXLJM0BTwzzPFCRd/0ZJ vt7YM9UrXqCKeEN5OJlEJFn+LBXBsCH+JR5Bn9+cVJG0wkiP90KORqsroxXm5Og1fDao 1Vpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=om4cb1e9PvD/eHqzbHq7Ps5c524OGWzByLwqLp0dJ98=; b=pOLHKc4is+3fLTvL5utBh9RXikAv1tZHLiS4ITfE3AB0gTqbIuFkceFuANGgnhqH7x k+hdLAuVc0rBUY+kPPmlKwRabtjSceBKIH5zaOXWf/KX4n2wsePNS3KoXcltOkD/rhnD 1BU9w2GXXqJK3GAdLAyBBZsuJJNcBdvs9A7CU9MT3SEmQ2SKafD6LXC5ATLSZHZIhvIf JptClsVfw45X1FyPW8bVPidvA8K2pCcMeo9aUwNABl1xMS7Kl28tLwcw+ZowB6Y/wgEP THZGe83ghTJ5yPD5bkXt4HAH0bLhkOf1Kub5Ys3V6TZEurLBXRVWp7I0vLT3dijMqwbj nG+w== X-Gm-Message-State: APzg51D56dMIE60tHePKDbo0fQeEidlAzOmt00DtbXj8LWYpjjcP5RJd ei8K4KHCxECNmAOsmzVqcpchBRyjy4Y= X-Google-Smtp-Source: ANB0Vdb5ngkx6YwG096+5tQZA1G97Z6MUxD2zbd5JWjNKEqj6murpRVRVub7KhBqQXChVwfMOsUa+g== X-Received: by 2002:a62:c9:: with SMTP id 192-v6mr4890348pfa.99.1534977122972; Wed, 22 Aug 2018 15:32:02 -0700 (PDT) Received: from tim-desktop (2001-44b8-31f2-bb00-d9ea-96bd-5b2a-4106.static.ipv6.internode.on.net. [2001:44b8:31f2:bb00:d9ea:96bd:5b2a:4106]) by smtp.gmail.com with ESMTPSA id r19-v6sm3439454pgg.39.2018.08.22.15.32.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 Aug 2018 15:32:02 -0700 (PDT) References: <47d3c240-73ef-9b00-64d5-6c2cfb4d9b18@commandprompt.com> User-agent: mu4e 0.9.18; emacs 26.1 From: Tim Cross To: "Joshua D. Drake" Cc: David Gauthier , pgsql-general@postgresql.org Subject: Re: Can Pg somehow recognize/honor linux groups to control user access ? In-reply-to: <47d3c240-73ef-9b00-64d5-6c2cfb4d9b18@commandprompt.com> Date: Thu, 23 Aug 2018 08:31:57 +1000 Message-ID: <87d0ua58yq.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Joshua D. Drake writes: > 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. > I think this is more an identity management problem rather than SSO (SSO can be considered a sub-topic within identity management). In this case, you are probably looking for some mix of 'single sign on' and 'same sign on', depending on business requirements. This is a large and complex problem which needs a 'whole of business' approach. Essentially, you need a single directory which is a 'source of truth' for all accounts. It manages usernames, user and group IDs, passwords and attributes representing what services and resources each individual is entitled to access. Downstream systems, such as PG, use the information in this central repository to manage authentication (username/password) and authorisation (which services and what roles within those services). A very common architecture is to have synchronised openLDAP and Active Directory as the centralised directory (source of truth) and some application which sits on top to manage the data in the directory servers (MS FIM/MIM, Oracle IDM, Dell Quest etc). How complex and large this ends up being really depends on the particulars of the environment i.e. size, mix of platforms, etc. I would start with either openLDAP or Active Directory (depending on environment) and then PAM if more fine grained control is required that cannot be satisfied via ldap/ad. Tim -- Tim Cross