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 1jSn4w-0007Lb-Tt for pgsql-admin@arkaria.postgresql.org; Sun, 26 Apr 2020 19:36:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jSn4v-0006a1-Ow for pgsql-admin@arkaria.postgresql.org; Sun, 26 Apr 2020 19:36:37 +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 1jSn4v-0006Zu-FZ for pgsql-admin@lists.postgresql.org; Sun, 26 Apr 2020 19:36:37 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jSn4p-0005Ba-TG for pgsql-admin@postgresql.org; Sun, 26 Apr 2020 19:36:37 +0000 Received: by mail-wr1-x42d.google.com with SMTP id b11so18028393wrs.6 for ; Sun, 26 Apr 2020 12:36:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=RTwOk0oJbsUviuTK5z/Ot050s9xkhYcwiPhYcqKRGok=; b=iPaclC+E8YuvYfzKXhvW+0xnqYg5Ay7o+vQWpjDBLzC1t5pnH6r/EqQJw7kNzI//sf KeQJJRPCIWjw6oU7M53jxflIhFRW60dL0siYIj22fij4xPjPnNQ9Ofz4RDfEybeK8xtW BCozDLx8SswN5usaSNvGGa5beY5/2SP2hrTvphgvjcvOjJI7dw63QIUXjUluQEwTm+/q JVn8jiZ4yPZYSX9Me2e5b/Lau6p+lPzyUxhNQTDo7c+RucYuOs8llZMe80qPe7zmAs2a +mYaqA019jnbrUcUMV1SkYDm3LgCa7RfPFff0Eh1AR/E9rhljpepZX/NCdxUSac3rIdN RSiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=RTwOk0oJbsUviuTK5z/Ot050s9xkhYcwiPhYcqKRGok=; b=aH4t+UHZFDZX5YsK/Sbu/PZWvpCBZS5C+eKCujF7sul+5N0PMgVlvq2kx+Ryt0oBeE Cms4r9ICi39TEDjbcvvvHUPGuO2SWpbmNsL0OE36SWvbR31XNHMtO0pild6UHoO4xPQ7 BHk/Uh4cmsaoHphlgt25HB3YNB39nel6rjMAT5vjmtF3Fhxair3gGOSdsE8RcjYWmWJ5 8FCbanrunlwQ8UVNR+8mWOeng+LQFmuBmcPnIwGB9Oh5KDlIcqSfS70BHxtvczlDZRiL /KeWp7BafZwNu4rYjtHRZjkuHAsWqkeK+CxGdr9kBWf/+n23yIiLqDJ/VoSCsuo5gMOJ sE+A== X-Gm-Message-State: AGi0PuYipcnPDkXT+ZhYHH0Ct3ZrciYDOhqoIUgY0wgYwkBtOlWNJGLC +JLAIAJ7g8H5d9ccbAbVL3JZaq3c X-Google-Smtp-Source: APiQypKvejkmrYSHI11q/2z2TbkyOIs6pN9JaQLsBRtKg1JqTLUcCopOtty/sV+1+09ZfbjvQuzxMg== X-Received: by 2002:a5d:68ca:: with SMTP id p10mr23596125wrw.154.1587929788860; Sun, 26 Apr 2020 12:36:28 -0700 (PDT) Received: from [192.168.1.212] (ip-5-186-124-33.cgn.fibianet.dk. [5.186.124.33]) by smtp.gmail.com with ESMTPSA id f63sm12291212wma.47.2020.04.26.12.36.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 26 Apr 2020 12:36:28 -0700 (PDT) Subject: Re: Setting up a database with minimum access rights To: Jeff Janes Cc: pgsql-admin References: From: Bo Victor Thomsen Message-ID: <90829287-de11-7949-061c-5eb914b73393@gmail.com> Date: Sun, 26 Apr 2020 21:36:51 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------F6DD9774EC52BBB9BAAD6823" Content-Language: en-GB List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------F6DD9774EC52BBB9BAAD6823 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hi Jeff - Spot on !!  (Right hand reaching for the Postgres manual,  left hand searching for "Brown paper bag to pull over head" ) I was executing the script with user "postgres" and creating the table with another user "greenadm_adm". With the missing qualifier "FOR USER.."  in the "ADD DEFAULT PRIVILEGES.. " command, the command only works for tables created by user "postgres". Using the same user for both scripting and creating tables works. I owe you a large cold beer (or whatever beverage you prefer) If we ever meet in person :-) -- Med venlig hilsen / Kind regards Bo Victor Thomsen Den 26-04-2020 kl. 19:37 skrev Jeff Janes: > On Sun, Apr 26, 2020 at 12:57 PM Bo Victor Thomsen > > wrote: > > ... > > After execution of the above commands, I create a table in schema > "data_schema" using the "postgres" superuser. But I can't access the > created table with user "loki" > > > Were all the above steps executed as "postgres", or was just the > CREATE TABLE statement done as that user? > > If it is all done as "postgres" superuser then it works for me.  Your > example ALTER DEFAULT PRIVILEGES without specifying the FOR ROLE only > applies to objects created by the same user who executed the ALTER > DEFAULT PRIVILEGES. > > Cheers, > > Jeff --------------F6DD9774EC52BBB9BAAD6823 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

Hi Jeff -

Spot on !!  (Right hand reaching for the Postgres manual,  left hand searching for "Brown paper bag to pull over head" )

I was executing the script with user "postgres" and creating the table with another user "greenadm_adm".

With the missing qualifier "FOR USER.."  in the "ADD DEFAULT PRIVILEGES.. " command, the command only works for tables created by user "postgres".

Using the same user for both scripting and creating tables works.

I owe you a large cold beer (or whatever beverage you prefer) If we ever meet in person :-)

-- 
Med venlig hilsen / Kind regards

Bo Victor Thomsen
Den 26-04-2020 kl. 19:37 skrev Jeff Janes:
On Sun, Apr 26, 2020 at 12:57 PM Bo Victor Thomsen <bo.victor.thomsen@gmail.com> wrote:

...
 
After execution of the above commands, I create a table in schema
"data_schema" using the "postgres" superuser. But I can't access the
created table with user "loki"

Were all the above steps executed as "postgres", or was just the CREATE TABLE statement done as that user?

If it is all done as "postgres" superuser then it works for me.  Your example ALTER DEFAULT PRIVILEGES without specifying the FOR ROLE only applies to objects created by the same user who executed the ALTER DEFAULT PRIVILEGES.

Cheers,

Jeff

  


--------------F6DD9774EC52BBB9BAAD6823--