pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Charles Clavadetscher <clavadetscher@swisspug.org>
To: 'Łukasz Jarych' <jaryszek@gmail.com>
Cc: 'Melvin Davidson' <melvin6925@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: RE: Read only to schema
Date: Sat, 28 Jul 2018 15:58:16 +0200
Message-ID: <066e01d4267b$1001e6e0$3005b4a0$@swisspug.org> (raw)
In-Reply-To: <CAGv31od3wOvQNHAvM9yob7Qzc4YtmNn1Tiu5Wc39+iZ7W_9ERA@mail.gmail.com>
References: <CAGv31odWvR7=_VPR=wVNkK3nNh5EHfEyEuMSUHW0TNFdHVjnXw@mail.gmail.com>
	<CAGv31odLZfO12niaO8KJYzm0V5NDExZHyCcGiGkOZzpj_fvkZA@mail.gmail.com>
	<CAGv31odcvi8GVXU3CZYEONCKHo_BmB3Qo5ZQy3XFf9TUyN8fpA@mail.gmail.com>
	<02ef01d41b3b$1e2fda60$5a8f8f20$@swisspug.org>
	<CAGv31oea+sd=BEZi3of40hOb056tfdSQMr=c6gGp2pc2KpL49Q@mail.gmail.com>
	<031b01d41b5d$dd73a880$985af980$@swisspug.org>
	<CAGv31oewbB-UJKEet4am2Vohncocrghbj05M8NWQ2FjJcxuWNA@mail.gmail.com>
	<041201d424f0$f6faf5a0$e4f0e0e0$@swisspug.org>
	<042301d424f3$08142da0$183c88e0$@swisspug.org>
	<CAGv31of9SjiFn7JqV10EDaT1T_psMXq9-0MgQYP+Sxq-UF56hg@mail.gmail.com>
	<CAGv31oepnaD+8ke457vQ7C7x5egmbEEhEcgwMHeqAMxRMfA25w@mail.gmail.com>
	<062101d425be$eaa4cd70$bfee6850$@swisspug.org>
	<CANu8FiwTLe9PAC0aD+jFoFq950DXvJMdEmdbusATJ2LWpaW7Zg@mail.gmail.com>
	<CAGv31od3wOvQNHAvM9yob7Qzc4YtmNn1Tiu5Wc39+iZ7W_9ERA@mail.gmail.com>

Hello Jakek

 

From: Łukasz Jarych [mailto:jaryszek@gmail.com] 
Sent: Samstag, 28. Juli 2018 14:13
To: Melvin Davidson <melvin6925@gmail.com>; pgsql-general@postgresql.org >> PG-General Mailing List <pgsql-general@postgresql.org>
Subject: Re: Read only to schema

 

Hi Guys,

 

thank you for such advances replies and help ! You are the best!

 

I have found out that this command:

 

GRANT ALL PRIVILAGES ON ALL TABLES IN SCHEMA schema_name TO role_name; 

 

Be aware that granting all privilege is not necessarily the best approach. You are granting e.g. a user the permission to create triggers on your table that can perform actions transparently or to truncate the table.

If this is really what you want and need, well, go for it. Otherwise restrict it to the privileges the user really needs, e.g.

 

GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA ...

 

Regards.

Charles

 

is working for me. 

 

I will read more and try to use it properly! 

 

Thank you very much, 

Best,

Jacek 

 

 

 

pt., 27 lip 2018 o 17:55 Melvin Davidson <melvin6925@gmail.com <mailto:melvin6925@gmail.com> > napisał(a):

Jacek, 
you appear to be confused on how security works in PostgreSQL.

Please review the options in 

 

https://www.postgresql.org/docs/10/static/sql-grant.html


and read the Description that follows on that page

As owner or superuser, you can
GRANT CONNECT {CREATE} ON DATABASE;
GRANT USAGE {CREATE} ON SCHEMA schema_name TO role_name;
GRANT SELECT ON TABLE table_name TO role_name;
GRANT SELECT ON ALL TABLES IN SCHEMA schema_name TO role_name;

What you want is probably the last of these.

If you are still confused, you should probably purchase 
or download 

PostgreSQL Administration Essentials
Chapter 3: Users and Permissions

from https://www.packtpub.com/all?search=PostgreSQL+Administration+Essentials <https://www.packtpub.com/all?search=PostgreSQL+Administration+Essentials&availability_list%5BAva...; &availability_list%5BAvailable%5D=Available&offset=&rows=&sort=

 

On Fri, Jul 27, 2018 at 11:31 AM, Charles Clavadetscher <clavadetscher@swisspug.org <mailto:clavadetscher@swisspug.org> > wrote:

Hi

 

Please notice that in this mailing list it is not customary to top post.

 

From: Łukasz Jarych [mailto:jaryszek@gmail.com <mailto:jaryszek@gmail.com> ] 
Sent: Freitag, 27. Juli 2018 12:19
To: Charles Clavadetscher <clavadetscher@swisspug.org <mailto:clavadetscher@swisspug.org> >; pgsql-general@postgresql.org <mailto:pgsql-general@postgresql.org>  >> PG-General Mailing List <pgsql-general@postgresql.org <mailto:pgsql-general@postgresql.org> >
Subject: Re: Read only to schema

 

Hi,

 

ok i hate this. 

 

SELECT datname, datacl FROM pg_database where datname = 'AccessLog'; 

 



\What does it mean?

 

The ACL (Access Control List) contains all the information about which role can do what on that object, in this case a database and which role granted the privileges.

 

You can find detailed information in the documentation:

https://www.postgresql.org/docs/10/static/sql-grant.html

 

An ACL is an array of aclitem, which again is basically a key/value pair with an equal sign between the key and the value.

In this context the key is the grantee, i.e. the role being granted a privilege.

The value is the list of privileges (see list following the link above) granted to that role, followed by a slash (/) and the role that granted the privilege.

The list of acronyms is a.o. in the link I gave above. Here for your convenience:

 

rolename=xxxx -- privileges granted to a role

        =xxxx -- privileges granted to PUBLIC

 

            r -- SELECT ("read")

            w -- UPDATE ("write")

            a -- INSERT ("append")

            d -- DELETE

            D -- TRUNCATE

            x -- REFERENCES

            t -- TRIGGER

            X -- EXECUTE

            U -- USAGE

            C -- CREATE

            c -- CONNECT

            T -- TEMPORARY

      arwdDxt -- ALL PRIVILEGES (for tables, varies for other objects)

            * -- grant option for preceding privilege

 

        /yyyy -- role that granted this privilege

 

If the key is empty, it means that the privilege is granted to public, i.e. every role.

 

Example:

 

admin=CTc/postgres means that role postgres granted Connect (c), Create (C) and Temporary (T) to role admin.

 

Notice that the granting role may differ from the one you are using, if you are acting as superuser:

 

“If a superuser chooses to issue a GRANT or REVOKE command, the command is performed as though it were issued by the owner of the affected object. In particular, privileges granted via such a command will appear to have been granted by the object owner. (For role membership, the membership appears to have been granted by the containing role itself.)”

 

If the ACL is empty (NULL) then the predefined default privileges apply. =

view thread (16+ messages)  latest in thread

Message-ID: <066e01d4267b$1001e6e0$3005b4a0$@swisspug.org>
Permalink:  ../066e01d4267b$1001e6e0$3005b4a0$@swisspug.org/
Also on:    postgresql.org/message-id/066e01d4267b$1001e6e0$3005b4a0$@swisspug.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: clavadetscher@swisspug.org, jaryszek@gmail.com, melvin6925@gmail.com
  Subject: Re: Read only to schema
  In-Reply-To: <066e01d4267b$1001e6e0$3005b4a0$@swisspug.org>
  References: <CAGv31odWvR7=_VPR=wVNkK3nNh5EHfEyEuMSUHW0TNFdHVjnXw@mail.gmail.com> <CAGv31odLZfO12niaO8KJYzm0V5NDExZHyCcGiGkOZzpj_fvkZA@mail.gmail.com> <CAGv31odcvi8GVXU3CZYEONCKHo_BmB3Qo5ZQy3XFf9TUyN8fpA@mail.gmail.com> <02ef01d41b3b$1e2fda60$5a8f8f20$@swisspug.org> <CAGv31oea+sd=BEZi3of40hOb056tfdSQMr=c6gGp2pc2KpL49Q@mail.gmail.com> <031b01d41b5d$dd73a880$985af980$@swisspug.org> <CAGv31oewbB-UJKEet4am2Vohncocrghbj05M8NWQ2FjJcxuWNA@mail.gmail.com> <041201d424f0$f6faf5a0$e4f0e0e0$@swisspug.org> <042301d424f3$08142da0$183c88e0$@swisspug.org> <CAGv31of9SjiFn7JqV10EDaT1T_psMXq9-0MgQYP+Sxq-UF56hg@mail.gmail.com> <CAGv31oepnaD+8ke457vQ7C7x5egmbEEhEcgwMHeqAMxRMfA25w@mail.gmail.com> <062101d425be$eaa4cd70$bfee6850$@swisspug.org> <CANu8FiwTLe9PAC0aD+jFoFq950DXvJMdEmdbusATJ2LWpaW7Zg@mail.gmail.com> <CAGv31od3wOvQNHAvM9yob7Qzc4YtmNn1Tiu5Wc39+iZ7W_9ERA@mail.gmail.com> <066e01d4267b$1001e6e0$3005b4a0$@swisspug.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox