Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jAET7-0005Cp-LT for pgsql-general@arkaria.postgresql.org; Fri, 06 Mar 2020 15:00:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jAET6-0005IW-1z for pgsql-general@arkaria.postgresql.org; Fri, 06 Mar 2020 15:00:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jAET5-0005IO-O6 for pgsql-general@lists.postgresql.org; Fri, 06 Mar 2020 15:00:51 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jAET3-0004C1-CF for pgsql-general@lists.postgresql.org; Fri, 06 Mar 2020 15:00:51 +0000 Received: by mail-wm1-x333.google.com with SMTP id a132so2790385wme.1 for ; Fri, 06 Mar 2020 07:00:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=/aE8TFbQ0hGjgnKlugB0e0KkHHPrAiiQT6pwgsE4cV4=; b=RfBMGoZETtSrnxZ7ZmKGe3InfJAMf8pv3kl1XtZYs7GOxAZ2Pom7ibIAR+HNxnYoS4 VYccOxdgdVHuwYrqSJfu87zq+GseLNs/PfV0wgwGHqd2JHzgEHy67BoNeSPO7dpLtV/G jgYxYQ77Iad0OM8w2knAoiHerLvgYmvtyWaue0JGwns4vj7eb0hDTqJC1Xc98rxe00gx 0lpIlTbMBY2uzOMgdVTg+UWYWE13REC+vF/Qn1+J9fVphzQROi32a6k3rRBT9SevtWR9 IyUnPFaZW/NU4hpA5AA5RTVh81XGf2BMrr7ZZRJno5aqSjdSSuMuWrwBKi2819Ykg37F MheA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=/aE8TFbQ0hGjgnKlugB0e0KkHHPrAiiQT6pwgsE4cV4=; b=ht3O9xEtn/IFTJA1SI3b7+4BOukZvyZ63B+CIhYKegNcuCWEkl5AwsiHo07nDRWXYm grb8pG9Enmzdayq0Nt7xz5dwH8Wecdokd+1joWT6ZyAgyxJcAUvACyJ8ZRTgzx5J5ssb dOqn3IeMp3Ri1orQEBnyKXdAQGB1NuCEpGllpMsxO+V5kehVNdx3w45In+1fAoOv7JD8 pu3cb0fJnOM/yNfqq16XooCLwwsjAXFvM/nIuTFw8F52BN92Bdst7c307pJW2+PV9cEY 9lQB1G4eC9iMODCju0++19eHRquNACA596xZzTtF+mMveu71SDYSMA4viWjbzybNcyV1 BlDw== X-Gm-Message-State: ANhLgQ1nrOQhNE2CSJANTi9fiIryU1JshQds4ByWDLuVXEz5MG4VK/lp PtQI7vAfguusKeo0upZcBU73ew== X-Google-Smtp-Source: ADFU+vuOFpxrdpA0MnZRG7Kht7Vf3OqZzAJUh3wydhVZePQwdQ2+3LwW9JDGfmoKN2MvBIVEBqE0Mg== X-Received: by 2002:a1c:964f:: with SMTP id y76mr4291427wmd.62.1583506848364; Fri, 06 Mar 2020 07:00:48 -0800 (PST) Received: from localhost.localdomain (217-149-169-0.nat.highway.telekom.at. [217.149.169.0]) by smtp.gmail.com with ESMTPSA id j205sm13772280wma.42.2020.03.06.07.00.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2020 07:00:47 -0800 (PST) Message-ID: <29d4aa524d0f9d88e9a98639a92e12d2cd966630.camel@cybertec.at> Subject: Re: How to allow users to create and modify tables only in their own schemas, but with generic table owner From: Laurenz Albe To: Schmid Andreas , "'pgsql-general@lists.postgresql.org'" Date: Fri, 06 Mar 2020 16:00:46 +0100 In-Reply-To: <523af9d43b78454882a270b0839fe5c1@bd.so.ch> References: <523af9d43b78454882a270b0839fe5c1@bd.so.ch> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, 2020-03-06 at 11:04 +0000, Schmid Andreas wrote: > I'd like to setup my database in a way that only a superuser may create schemas, > then grants permission to a specific user to create tables inside this schema. > This should work so far with GRANT CREATE ON SCHEMA ... TO user_a. > However I want the table owner not to be the user that creates the tables. > Instead the owner should rather be a generic role (e.g. table_owner), and the > owner should be the same over all tables of the whole database. This would work, > too, if I grant membership in role table_owner to all users that may create tables. > (The users must issue a SET ROLE table_owner before creating tables.) Yes, that will work, but you have to SET ROLE before creating the table. > What I didn't achieve so far is making sure that user_a who created tables in schema_a > cannot crete/modify tables of schema_b that were created by user_b. Do you see any way > to achieve this, while still sticking to that generic owner role? No, that is impossible. But I don't understand the motivation: If you want that, why would you want a "table_owner" role? If you don't want user B to be able to drop user A's table, why don't you have each user be the owner of his tables? Yours, Laurenz Albe