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 1q5LVf-0003Xz-7h for pgsql-general@arkaria.postgresql.org; Sat, 03 Jun 2023 07:17:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q5LVd-0006oo-Uf for pgsql-general@arkaria.postgresql.org; Sat, 03 Jun 2023 07:17:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q5LVd-0006j2-JB for pgsql-general@lists.postgresql.org; Sat, 03 Jun 2023 07:17:09 +0000 Received: from portal-smtp-out.hot.ee ([194.126.101.125]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q5LVZ-003Nwf-Fe for pgsql-general@postgresql.org; Sat, 03 Jun 2023 07:17:08 +0000 Received: from localhost (localhost [127.0.0.1]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id 42A814DBC for ; Sat, 3 Jun 2023 10:17:01 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at vm-hot-relay10.estpak.ee Received: from portal-smtp-out.hot.ee ([127.0.0.1]) by localhost (vm-hot-relay10.estpak.ee [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1CXLC+I0L1G0 for ; Sat, 3 Jun 2023 10:16:58 +0300 (EEST) Received: from mail.hot.ee (hot-relayhost1.estpak.ee [213.180.2.79]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id A6DD94DA4 for ; Sat, 3 Jun 2023 10:16:58 +0300 (EEST) Content-Type: multipart/alternative; boundary="------------evBMxuGzuPXFtIC8JslmDZ0R" Message-ID: <568e6761-d224-7c72-59f3-267b39bde227@hot.ee> Date: Sat, 3 Jun 2023 10:16:54 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Content-Language: et To: pgsql-general From: Andrus Subject: How to remove user specific grant and revoke 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. --------------evBMxuGzuPXFtIC8JslmDZ0R Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit User groups table is defined as     CREATE TABLE IF NOT EXISTS public.kaspriv     (         id serial primary key,         user character(10) NOT NULL,         group character(35) NOT NULL     ...     ) There are hundreds of users. Earlier time grant and revoke commands were executed for every user separately. Later revoke and grant commands for public were added:     REVOKE ALL ON TABLE public.kaspriv FROM PUBLIC;     GRANT SELECT ON TABLE public.kaspriv TO PUBLIC; pgAdmin SQL tab still shows revoke and grant commands for every user also:     REVOKE ALL ON TABLE public.kaspriv FROM PUBLIC;     REVOKE ALL ON TABLE public.kaspriv FROM someuser;     REVOKE ALL ON TABLE public.kaspriv FROM someotheruser;     ...     GRANT SELECT ON TABLE public.kaspriv TO PUBLIC;     GRANT SELECT ON TABLE public.kaspriv TO someuser;     GRANT SELECT ON TABLE public.kaspriv TO someother;     ... How to remove those unnecessary user-specific GRANT and REVOKE commands to make rights cleaner? pgAdmin does not have delete option for those. Something like     DROP REVOKE ALL ON TABLE public.kaspriv FROM all EXCEPT public;     DROP GRANT SELECT ON TABLE public.kaspriv FROM all EXCEPT public; This will be one-time action. It can be done manually in pgadmin or using some script running once. Using     PostgreSQL 12.2 (Debian 12.2-2.pgdg100+1) on x86_64-pc-linux-gnu,     compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit and latest pgAdmin 7.2 Posted also in https://stackoverflow.com/questions/76394896/how-to-remove-unnecessary-grant-and-revoke-privileges-from-table Andrus. --------------evBMxuGzuPXFtIC8JslmDZ0R Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

User groups table is defined as

    CREATE TABLE IF NOT EXISTS public.kaspriv
    (
        id serial primary key,
        user character(10) NOT NULL,
        group character(35) NOT NULL
    ...
    )

There are hundreds of users. Earlier time grant and revoke commands were executed for every user separately. Later revoke and grant commands for public were added:

    REVOKE ALL ON TABLE public.kaspriv FROM PUBLIC;
    GRANT SELECT ON TABLE public.kaspriv TO PUBLIC;

pgAdmin SQL tab still shows revoke and grant commands for every user also:

    REVOKE ALL ON TABLE public.kaspriv FROM PUBLIC;
    REVOKE ALL ON TABLE public.kaspriv FROM someuser;
    REVOKE ALL ON TABLE public.kaspriv FROM someotheruser;
    ...
    GRANT SELECT ON TABLE public.kaspriv TO PUBLIC;
    GRANT SELECT ON TABLE public.kaspriv TO someuser;
    GRANT SELECT ON TABLE public.kaspriv TO someother;
    ...

How to remove those unnecessary user-specific GRANT and REVOKE commands to make rights cleaner? pgAdmin does not have delete option for those.

Something like

    DROP REVOKE ALL ON TABLE public.kaspriv FROM all EXCEPT public;
    DROP GRANT SELECT ON TABLE public.kaspriv FROM all EXCEPT public;

This will be one-time action. It can be done manually in pgadmin or using some script running once.

Using

    PostgreSQL 12.2 (Debian 12.2-2.pgdg100+1) on x86_64-pc-linux-gnu,
    compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit

and latest pgAdmin 7.2

Posted also in https://stackoverflow.com/questions/76394896/how-to-remove-unnecessary-grant-and-revoke-privileges-from-table

Andrus.

--------------evBMxuGzuPXFtIC8JslmDZ0R--