Help me understanding the schema

--00504502ca69d1212304799fb64a
Content-Type: text/plain; charset=UTF-8

hi, i've used postgresql for few months now, but i still don't understand
about the schema/database part and it's security consideration..
was there any better documentation (with pictures ^^) than this:
http://www.postgresql.org/docs/current/static/ddl-schemas.ht ml

so, here's my current statement, if someone kind enough to correct me,
please tell me if its right or wrong:
1. one database may contain many schema
2. one schema may contain many objects (tables, functions, etc)
3. multiple user can connect to single database
4. when the schema not defined on queries, it's always search from public
schema
5. tables created on schema x, can be joined using query on other schema
6. schema are related to database not the user, so, if we create a schema,
it shows on others user as well that having access to that database?
7. we can set the privilege of user x for schema y
ie. database aaa contains schema a1, a2 and a3. user xx can query from
schema a1 only, user yy can query from schema a2 only?
8. tables on one schema not related to other schema? it means when i create
table on schema x, it won't show on schema y..
9. so the best practice of database security is:
- create multiple schema, only relate schema to required user, eg. finance
schema can only be accessed by finance people, humanresource schema can only
be accessed by humanresource people..
- do not allow queries/manipulation from users, always use views for
queries/stored-procedure for manipulation/trigger for data integrity or
protection and set the privilege to specific user?
- on web application, set the running user (of the CGI process) to sameuser
login type, so we don't need to store any password on file.

--
Regards,
Kiswono P
GB

--00504502ca69d1212304799fb64a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

hi, i've used postgresql for few months now, but i still don't unde=
rstand about the schema/database part and it's security consideration..=
<div>was there any better documentation (with pictures ^^) than this:=C2=A0=
<a href=3D"http://www.postgresql.org/docs/current/static/ddl-schemas.html">=
http://www.postgresql.org/docs/current/static/ddl-schemas.ht ml</a></div>
<div><br></div><div>so, here's my current statement, if someone kind en=
ough to correct me, please tell me if its right or wrong:</div><div>1. one =
database may contain many schema</div><div>2. one schema may contain many o=
bjects (tables, functions, etc)</div>
<div>3. multiple user can connect to single database</div><div>4.=C2=A0when=
the schema not defined on queries, it's always search from public sche=
ma</div><div>5. tables created on schema x, can be joined using query on ot=
her schema</div>
<div>6. schema are related to database not the user, so, if we create a sch=
ema, it shows on others user as well that having access to that database?<b=
r>7. we can set the privilege of user x for schema y</div><div>=C2=A0=C2=A0=
ie. database aaa contains schema a1, a2 and a3. user xx can query from sche=
ma a1 only, user yy can query from schema a2 only?</div>
<div>8. tables on one schema not related to other schema? it means when i c=
reate table on schema x, it won't show on schema y..</div><div>9. so th=
e best practice of database security is:</div><div>=C2=A0- create multiple =
schema, only relate schema to required user, eg. finance schema can only be=
accessed by finance people, humanresource schema can only be accessed by h=
umanresource people..</div>
<div>=C2=A0- do not allow queries/manipulation from users, always use views=
for queries/stored-procedure for manipulation/trigger for data integrity o=
r protection and set the privilege to specific user?</div><div>=C2=A0- on w=
eb application, set the running user (of the CGI process) to sameuser login=
type, so we don't need to store any password on file.<br>
<div><br>-- <br>Regards,<br>Kiswono P<br>GB<br>
</div></div>

--00504502ca69d1212304799fb64a--
Kiswono Prayogo [ Di, 01 Dezember 2009 01:19 ] [ ID #2024895 ]

Re: Help me understanding the schema

On Mon, Nov 30, 2009 at 5:19 PM, Kiswono Prayogo <kiswono [at] gmail.com> wrote:
> hi, i've used postgresql for few months now, but i still don't understand
> about the schema/database part and it's security consideration..
> was there any better documentation (with pictures ^^) than
> this:=A0http://www.postgresql.org/docs/current/static/ddl-sc hemas.html
> so, here's my current statement, if someone kind enough to correct me,
> please tell me if its right or wrong:
> 1. one database may contain many schema
> 2. one schema may contain many objects (tables, functions, etc)
> 3. multiple user can connect to single database
Yes, yes, yes.

> 4.=A0when the schema not defined on queries, it's always search from publ=
ic
> schema
No, but close. It uses the schemas as listed, in order, in
search_path, which defaults to $user, public.

> 5. tables created on schema x, can be joined using query on other schema
> 6. schema are related to database not the user, so, if we create a schema,
> it shows on others user as well that having access to that database?
yes, yes.

> 7. we can set the privilege of user x for schema y
> =A0=A0ie. database aaa contains schema a1, a2 and a3. user xx can query f=
rom
> schema a1 only, user yy can query from schema a2 only?
No, perms on schemas control schema actions like create. perms on
tables control user access.

> 8. tables on one schema not related to other schema? it means when i crea=
te
> table on schema x, it won't show on schema y..
yes.

> 9. so the best practice of database security is:
> =A0- create multiple schema, only relate schema to required user, eg. fin=
ance
> schema can only be accessed by finance people, humanresource schema can o=
nly
> be accessed by humanresource people..
Yes, but the perms are set per table, not schema. Use roles, so that
you grant access to finance tables for update to the finance role,
then grant that role to individual users as needed. Revoke that role
from users to revoke access.

> =A0- do not allow queries/manipulation from users, always use views for
> queries/stored-procedure for manipulation/trigger for data integrity or
> protection and set the privilege to specific user?
Yes and no. This doesn't make things any safer really. However, using
functions and triggers can allow you to encapsulate business logic in
such a way as to make life easier for the user as well as you.

> =A0- on web application, set the running user (of the CGI process) to sam=
euser
> login type, so we don't need to store any password on file.

This is only reliable if you have identd and are running everything on
one server.

--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Scott Marlowe [ Sa, 05 Dezember 2009 21:53 ] [ ID #2024897 ]

Re: Help me understanding the schema

Hi Scott,

>> 7. we can set the privilege of user x for schema y
>> ie. database aaa contains schema a1, a2 and a3. user xx can query from
>> schema a1 only, user yy can query from schema a2 only?
> No, perms on schemas control schema actions like create. perms on
> tables control user access.

I thought that a user also had to have the USAGE right on a schema? In an =
application I'm working on at the moment, it threw the error "permission de=
nied on schema xxx" even if permissions on the tables within the schema wer=
e OK - I had to assign the USAGE right on the schema.

Regards,
Andy
--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
andy-lists [ Sa, 05 Dezember 2009 23:08 ] [ ID #2024898 ]

Re: Help me understanding the schema

Le samedi 5 d=E9cembre 2009 =E0 23:08:58, Andy Shellam (Mailing Lists) a =
=E9crit :
> Hi Scott,
>
> >> 7. we can set the privilege of user x for schema y
> >> ie. database aaa contains schema a1, a2 and a3. user xx can query fr=
om
> >> schema a1 only, user yy can query from schema a2 only?
> >
> > No, perms on schemas control schema actions like create. perms on
> > tables control user access.
>
> I thought that a user also had to have the USAGE right on a schema? In an
> application I'm working on at the moment, it threw the error "permission
> denied on schema xxx" even if permissions on the tables within the schema
> were OK - I had to assign the USAGE right on the schema.
>

You're right. One needs USAGE right to use the schema, and CREATE right to=

create objects in this schema.


--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com

--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Guillaume Lelarge [ Sa, 05 Dezember 2009 23:46 ] [ ID #2024899 ]

Re: Help me understanding the schema

On Sat, Dec 5, 2009 at 3:46 PM, Guillaume Lelarge
<guillaume [at] lelarge.info> wrote:
> Le samedi 5 d=E9cembre 2009 =E0 23:08:58, Andy Shellam (Mailing Lists) a =
=E9crit :
>> Hi Scott,
>>
>> >> 7. we can set the privilege of user x for schema y
>> >> =A0 ie. database aaa contains schema a1, a2 and a3. user xx can query=
from
>> >> schema a1 only, user yy can query from schema a2 only?
>> >
>> > No, perms on schemas control schema actions like create. =A0perms on
>> > tables control user access.
>>
>> I thought that a user also had to have the USAGE right on a schema? =A0I=
n an
>> =A0application I'm working on at the moment, it threw the error "permiss=
ion
>> =A0denied on schema xxx" even if permissions on the tables within the sc=
hema
>> =A0were OK - I had to assign the USAGE right on the schema.
>>
>
> You're right. One needs USAGE right to use the schema, and CREATE right to
> create objects in this schema.

I completely missed that in the docs. Thanks for the catch.

--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Scott Marlowe [ So, 06 Dezember 2009 00:15 ] [ ID #2024949 ]
Datenbanken » gmane.comp.db.postgresql.admin » Help me understanding the schema

Vorheriges Thema: Question about replication options
Nächstes Thema: Practice of backups