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 1ntsBJ-00086S-6B for pgsql-general@arkaria.postgresql.org; Wed, 25 May 2022 14:40:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ntsBH-0007pO-8S for pgsql-general@arkaria.postgresql.org; Wed, 25 May 2022 14:40:11 +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 1nts9l-0002cA-Lb for pgsql-general@lists.postgresql.org; Wed, 25 May 2022 14:38:37 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nts9j-0004h2-Go for pgsql-general@lists.postgresql.org; Wed, 25 May 2022 14:38:37 +0000 Received: by mail-pl1-x630.google.com with SMTP id n8so18757956plh.1 for ; Wed, 25 May 2022 07:38:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to; bh=3CthlBcWx73uw5HPBWf0oaZ7Ik9e2H2Y6SBlcwyk0k8=; b=PMA0pAEtD9vyTB34NOBqway1T38XjgOBfHhwoJm6uAvtMzCHUCFO8QXvDt9NS1mArW YnsWNJNJSN2INfepZsCeDaCiDAxQDZoFMrlGwfmUef6kFw2y6cMkRSEMOt7DxKF9/ZU2 PnPCuzGdvPd0dv+YrmKrGL7sqDCJF1x9+YVXyXXjRLx6Kz9DWOvB2JbU0zgWuHj+lQxC b2W8naxUOu7j/9dXmpljTApPkYDzSpHfrxXgy0d4UnZdOjvNjAPYjH4inmOaas73j5I1 XmAfVl1xmuNfQOPLb9VUky2yIvxVSjK2QD0M7x4PDzFGAfyrFxANg5V2HYGLnnCoKjSY cBVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to; bh=3CthlBcWx73uw5HPBWf0oaZ7Ik9e2H2Y6SBlcwyk0k8=; b=Q6vOEn+9IXoaeDsqKBSJjGPB4RC7ISfq+PjMFD4eKkjQcc3seq2lsR3YRr3TCbY7cT ek34uvJ6yQAJbZNvlxINVfp0jQL8XxdNb3QpV+NIJqWtFstKvwqtOie3NhozaAZkkcDD fDbpYnPiJiDWHgl1jWfcHIAe+sEY/szhdllB+5StnobrIG7wWLDAGMIStxR1YseuQPcw lkNFSxwt1XXdAmISqLMMm01unuxx/yvJ8R+pkKVFN44o7azZZxzbo/HNuy1jKtdcomb1 8RR1nQZsf7Bm54zsa2Si7bNaRJED9MuWu0IWEP3tL7A/rW4FTEJJTGqTI7LVficqT7A5 qEgA== X-Gm-Message-State: AOAM531BhhxwDld4wbdiAjcIFb98+MhI/9Qm4yT5Gcl2FL25ZzpyTOWC dwwbVPASfl+tDeJj9Zcgw90= X-Google-Smtp-Source: ABdhPJwxLMGqm82JbMWuAdUR7Ib5lax5hNJDIUhj/WsaM2gGbEFKfz0+fJw9zPVRN/ydpYkDPI3HXg== X-Received: by 2002:a17:90b:4c4e:b0:1e0:aafe:a11 with SMTP id np14-20020a17090b4c4e00b001e0aafe0a11mr3937779pjb.83.1653489513341; Wed, 25 May 2022 07:38:33 -0700 (PDT) Received: from [10.128.71.194] ([155.98.131.2]) by smtp.gmail.com with ESMTPSA id w16-20020a17090a461000b001e0bf3d4b63sm712771pjg.25.2022.05.25.07.38.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 May 2022 07:38:32 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------sKzyr031JR2cbtDLRy0Av0x0" Message-ID: Date: Wed, 25 May 2022 08:38:31 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: connect permission based on database name Content-Language: en-CA To: Tom Lane Cc: "pgsql-generallists.postgresql.org" References: <3659d499-9a98-6362-7c33-d8f2947474b4@gmail.com> <1920549.1653488423@sss.pgh.pa.us> From: Rob Sargent In-Reply-To: <1920549.1653488423@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------sKzyr031JR2cbtDLRy0Av0x0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 5/25/22 08:20, Tom Lane wrote: > Rob Sargent writes: >> Just wondering if I've bumped into some security issue. >> I'm somewhat surprised that "grant connect to database   to >> " appears to be stored "by name"? > I think you are forgetting that databases have a default GRANT CONNECT > TO PUBLIC. You need to revoke that before other grants/revokes will > have any functional effect. > > regards, tom lane And then the search path is "just a string"? psql --user oldrole --dbname newdb --host $DBHOST psql (12.11, server 12.7) SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) Type "help" for help. newdb=> show search_path;     search_path --------------------  study, base, public (1 row) --------------sKzyr031JR2cbtDLRy0Av0x0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 5/25/22 08:20, Tom Lane wrote:
Rob Sargent <robjsargent@gmail.com> writes:
Just wondering if I've bumped into some security issue.
I'm somewhat surprised that "grant connect to database <dbname>  to 
<role>" appears to be stored "by name"?
I think you are forgetting that databases have a default GRANT CONNECT
TO PUBLIC.  You need to revoke that before other grants/revokes will
have any functional effect.

			regards, tom lane
And then the search path is "just a string"?
psql --user oldrole --dbname newdb --host $DBHOST
psql (12.11, server 12.7)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.

newdb=> show search_path;
    search_path
--------------------
 study, base, public
(1 row)


--------------sKzyr031JR2cbtDLRy0Av0x0--