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 1odRGv-0001do-My for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Sep 2022 07:14:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1odRGu-0001wL-IC for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Sep 2022 07:14:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1odRGu-0001wC-6r for pgsql-hackers@lists.postgresql.org; Wed, 28 Sep 2022 07:14:20 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1odRGr-00068M-9Y for pgsql-hackers@lists.postgresql.org; Wed, 28 Sep 2022 07:14:19 +0000 Received: by mail-wm1-x331.google.com with SMTP id r3-20020a05600c35c300b003b4b5f6c6bdso505237wmq.2 for ; Wed, 28 Sep 2022 00:14:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date; bh=ql2ti64A8/SGd/H9SZcVTQpYhZkxPkyCXYnmebtWZx8=; b=SPBzfCU7veC0AvoEDSyI3YLRaznvMNsCBoMAE5K9LiTHC5rnnIQr5ZynGpPq40perh YOidTKxk1ge+o042CYST2FAv/q6t8WWRxkdeVOLxLUSe95THzjqqOzZn7avH+A/giro4 KNePevrYZpsYKXkdDi4Q76Me8q6ugAQl7ZqK1ArLDbktt3RnBgKt0f6DrAVmdELDQM8P JFCbDHu/ouVl2Vt653WFkHKne28oB/Y3eyg2GkLU3pPhoSEQnhLOE+COpeNKUTuuE5fD jV+JLpQ3Vx4Qdyau/Rrxhign3GrHYLD3HFQbCWxBp9+nykcpevdXLYna04/zcNMGwLJJ cgHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=ql2ti64A8/SGd/H9SZcVTQpYhZkxPkyCXYnmebtWZx8=; b=cBLl4MWawygnUHY5rVezMabglEzlZOoWTZSaoYW7yuoI/uTx3VCr8G1E7ca6Uu0a1+ kxj7qhKbFelRWobhkz4Ud6UR5sOOQNYXJBPifWA+Y1WvAibkCaFrR7RHn0qNO5ygO9U6 FhaO3LnZWyO1sJwsaUgep+ZHT8wUQtZg6e33F+KRGIgvptjTGBswPxy3FawdsWBewmUs /ubkC8IkUTx3UuhaAhnFE7F1Ivc3ouBZPLNFuhre0gC6B5oJcczt75RgeFv1ATBllC6V L0Xi2L3sBpN5TDN0eogiL12VQvtlooWDBFDLqWEvWAmOOwfBtbeUH+hwsXrnET19WRa3 oahA== X-Gm-Message-State: ACrzQf2/ITpwnvS7ZDVJG47FPiMIYPZWfOO0Us18VvHjJ14WYxlRR2yu NryztpA1sXWrQuTfMoP8jt8= X-Google-Smtp-Source: AMsMyM5fzcMOKYNe8K7J9MsaLeWZvFtS8vySGYNzJnQJ1YMRpXLhLdg/Q+LkCQCk1w3ErpD3HRE5rw== X-Received: by 2002:a05:600c:601f:b0:3b5:608:a411 with SMTP id az31-20020a05600c601f00b003b50608a411mr5551233wmb.178.1664349254953; Wed, 28 Sep 2022 00:14:14 -0700 (PDT) Received: from [192.168.31.157] ([54.239.6.188]) by smtp.gmail.com with ESMTPSA id n2-20020adffe02000000b0022ac119fcc5sm1485750wrr.60.2022.09.28.00.14.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Sep 2022 00:14:14 -0700 (PDT) Message-ID: <2ecffb46-8b0c-83cb-2577-bf83262b5f10@gmail.com> Date: Wed, 28 Sep 2022 09:12:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH] Add peer authentication TAP test Content-Language: en-US To: Michael Paquier Cc: PostgreSQL Hackers References: From: "Drouvot, Bertrand" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 9/28/22 7:52 AM, Michael Paquier wrote: > On Fri, Aug 26, 2022 at 10:43:43AM +0200, Drouvot, Bertrand wrote: >> During the work in [1] we created a new TAP test to test the SYSTEM_USER >> behavior with peer authentication. >> >> It turns out that there is currently no TAP test for the peer >> authentication, so we think (thanks Michael for the suggestion [2]) that >> it's better to split the work in [1] between "pure" SYSTEM_USER related work >> and the "pure" peer authentication TAP test work. >> >> That's the reason of this new thread, please find attached a patch to add a >> new TAP test for the peer authentication. > > +# Get the session_user to define the user name map test. > +my $session_user = > + $node->safe_psql('postgres', 'select session_user'); > [...] > +# Define a user name map. > +$node->append_conf('pg_ident.conf', qq{mypeermap $session_user testmap$session_user}); > + > +# Set pg_hba.conf with the peer authentication and the user name map. > +reset_pg_hba($node, 'peer map=mypeermap'); > > A map consists of a "MAPNAME SYSTEM_USER PG_USER". Why does this test > use a Postgres role (from session_user) as the system user for the > peer map? Thanks for looking at it! Initially selecting the session_user with a "local" connection and no user provided during the connection is a way I came up to retrieve the "SYSTEM_USER" to be used later on in the map. Maybe the variable name should be system_user instead or should we use another way to get the "SYSTEM_USER" to be used in the map? Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com