Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oozjH-0006jy-Oj for pgsql-general@arkaria.postgresql.org; Sun, 30 Oct 2022 04:15:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oozjF-0000SY-O5 for pgsql-general@arkaria.postgresql.org; Sun, 30 Oct 2022 04:15:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oozjE-0000SJ-6H for pgsql-general@lists.postgresql.org; Sun, 30 Oct 2022 04:15:21 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oozj6-0005ef-Or for pgsql-general@lists.postgresql.org; Sun, 30 Oct 2022 04:15:19 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id AB1585C00DF; Sun, 30 Oct 2022 00:15:09 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 30 Oct 2022 00:15:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1667103309; x= 1667189709; bh=AtnPp59yfsoNY4or8DUKsD1a0l8E5FIWdN0R1OERjy4=; b=I oSgjp/ByjIWjJsg85SsqLqpzddgeOgY15glmGgWn4G14Vjb8cNvVOXeowo8nmGVX Zdw3Qhywn5T8PybbqNEDlJs3p0P+9yQXie+ZhcrH8kOh5S9+ZN+2SpteyCFJyUHo zb8ybycRLxs9Nihvbk2nVCU0BcFiJhvJ6qorBnptYuJB9AFKBS6s9E9JxRA2wxEI 9l4gee27B4pHCr4CuI+Z9eck7T3dffINsMKVKegDh+0Tojv32qZE244k0Qxeriii zOYgdOsum/F+UeWzsNckmh3mRAEqA3sJg/OVIap+mmvpum8NpitTsnWBhe5l90SP 0hH+hd94hg9MRv767HkGA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1667103309; x= 1667189709; bh=AtnPp59yfsoNY4or8DUKsD1a0l8E5FIWdN0R1OERjy4=; b=K vb9i1lRqyLqHpK2PSmw/qDxbxKIVwN2cHnQPcAm8u0k+rmuLkH/sy5dd+N4KtG// DZ/Z75dyG2fUueGFfKxCxIXqBE3JlyqBFuiNdbkacmw6Kwe8SewkElPZfqC5xgbO wQfhNCw6rbfQiwckCwy7b7pCl5fNLSpITgf0R/bqteOgxhhNPMOkb09sIN8SdKHV UKLWrJb4pyl9Z7HLA7qp8E1E/l99TimA8soV21DjRv9pzDXH6LTn0fVFKP/Y5glz FyttEw0suHTvNrzeu9f1s86KUUfa+hY2W1nEvIErlsC8yyqxIADg2Z9ZjoWJ6bbR w2Lb0ijQe345ikgg/pW8A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrtdelgdektdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfevfhfhjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeehudfgtefhtedtheeiveetueektdejvdfhveekgfdu feegveetuddvuedvgeeggeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 30 Oct 2022 00:15:08 -0400 (EDT) Message-ID: <533103a6-044d-0047-91e8-9bcbce94b9a3@aklaver.com> Date: Sat, 29 Oct 2022 21:15:08 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should Content-Language: en-US To: "David G. Johnston" , Bryn Llewellyn Cc: pgsql-general list References: <9801E977-425C-41BF-B024-19BC875940C0@icloud.com> From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 10/29/22 20:38, David G. Johnston wrote: > On Sat, Oct 29, 2022 at 8:20 PM Bryn Llewellyn > wrote:This is what I want: > > > 1. I want to do this at the O/S prompt on the machine where my PG > cluster has been started: *"su mary"*. > > 2. Then I want to start a session (I use "psql" here an an example) > like this: *"psql -d postgres"*. > > 3. Then, at the "psql" prompt, I want *"select session_user"* to > show "bob". > > > I seriously do not understand why in the world you want an > authentication system where you tell the server "my user name is mary" > and expect the server to then say "ok, but I'm going to log you in as > bob just for the fun of it".  The way I see it, when I tell the server > "my user name is mary", upon successful completion of the login I am > logged in as, wait for it........., mary. > > *Peer authentication failed for user "mary"* > > I assume that the phrase « user "mary" » means the O/S user "mary". > > > No, the server is never going to give you an error message with your o/s > user name showing.  It is going to tell you "no, you may not login as > mary, because your name is bob and I have not been informed that you, > bob, are allowed to login as the user mary in this cluster". > > Next, I put an identity mapping in for "mary" in "pg_ident.conf" thus: > > *# MAPNAME    SYSTEM-USERNAME   PG-USERNAME* > *# -------    ---------------   ----------- >   bllewell   mary              mary > * > > > As has been said numerous times, it is utterly pointless to define a > mapping like this - you get mary-is-mary for free just by saying peer. +1 > > ** > So, "bob" is the simple case. And "mary" is one step harder. Now, > the unqualified "psql -d postgres" works again for "mary" (and it > still works, of course, for "bob"). > > So far, so good. Now for the test, I mapped "mary" to "bob" in > "pg_ident.conf" thus: > > *# MAPNAME    SYSTEM-USERNAME   PG-USERNAME > # -------    ---------------   ----------- >   bllewell   mary              bob > * > > > Now you are saying mary is allow to claim she is bob.  Which requires > the o/s user to be mary and her psql command line have "-U bob" > > It is not possible to make an alias mapping work without specifying "-U" > on the psql command line.  Period.  The -U is precisely how you tell the > server you are using an alias - without it the server expects that the > o/s user is logging in using their own name as the requested login > role.  In that case either a peer entry for the user exists - and thus > authentication is successful - or it doesn't - and authentication will fail. +1 > > David J. > -- Adrian Klaver adrian.klaver@aklaver.com