pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: David G. Johnston <david.g.johnston@gmail.com>
To: Bryn Llewellyn <bryn@yugabyte.com>
Cc: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should
Date: Sat, 29 Oct 2022 21:15:08 -0700
Message-ID: <533103a6-044d-0047-91e8-9bcbce94b9a3@aklaver.com> (raw)
In-Reply-To: <CAKFQuwY1WNB=ikgazfriLg_TkJO_bQw36gAdhx7WN-OoGnsaSQ@mail.gmail.com>
References: <9801E977-425C-41BF-B024-19BC875940C0@icloud.com>
	<b6bc9855-a4bb-d9a3-a60e-bf3bf6be9332@aklaver.com>
	<C5AE5E6F-C584-42C9-A871-FD992BDB021C@yugabyte.com>
	<CAKFQuwY1WNB=ikgazfriLg_TkJO_bQw36gAdhx7WN-OoGnsaSQ@mail.gmail.com>

On 10/29/22 20:38, David G. Johnston wrote:
> On Sat, Oct 29, 2022 at 8:20 PM Bryn Llewellyn <bryn@yugabyte.com 
> <mailto:bryn@yugabyte.com>> 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






view thread (13+ messages)  latest in thread

Message-ID: <533103a6-044d-0047-91e8-9bcbce94b9a3@aklaver.com>
Permalink:  ../533103a6-044d-0047-91e8-9bcbce94b9a3@aklaver.com/
Also on:    postgresql.org/message-id/533103a6-044d-0047-91e8-9bcbce94b9a3@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, david.g.johnston@gmail.com, bryn@yugabyte.com
  Subject: Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should
  In-Reply-To: <533103a6-044d-0047-91e8-9bcbce94b9a3@aklaver.com>
  References: <9801E977-425C-41BF-B024-19BC875940C0@icloud.com> <b6bc9855-a4bb-d9a3-a60e-bf3bf6be9332@aklaver.com> <C5AE5E6F-C584-42C9-A871-FD992BDB021C@yugabyte.com> <CAKFQuwY1WNB=ikgazfriLg_TkJO_bQw36gAdhx7WN-OoGnsaSQ@mail.gmail.com> <533103a6-044d-0047-91e8-9bcbce94b9a3@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox