Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D54EB47626B for ; Thu, 21 Nov 2002 12:54:49 -0500 (EST) Received: from rwcrmhc53.attbi.com (rwcrmhc53.attbi.com [204.127.198.39]) by postgresql.org (Postfix) with ESMTP id F0C4447622E for ; Thu, 21 Nov 2002 12:54:48 -0500 (EST) Received: from prometheus (h00a0cc2215a7.ne.client2.attbi.com[24.128.58.146]) by rwcrmhc53.attbi.com (rwcrmhc53) with SMTP id <200211211754530530025ps5e>; Thu, 21 Nov 2002 17:54:54 +0000 Message-ID: <006001c29188$6516ad80$923a8018@prometheus> From: "Dan MacNeil" To: Subject: pg_hba.conf file Date: Thu, 21 Nov 2002 13:03:54 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_005D_01C2915E.71F01CF0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4920.2300 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4920.2300 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/218 X-Sequence-Number: 6406 This is a multi-part message in MIME format. ------=_NextPart_000_005D_01C2915E.71F01CF0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable It would be great if somebody could review our pg_hha.conf file below to se= e if it does what we want it to, no more and no less. The goals for our pg_hba.conf file are: 1) In an emergency allow somebody with operatating=20 system root privs access to all the databases with full privs. 2) Allow local shell users to connect to databases named after=20 themselves wit no authentification.=20=20=20 a) As we run suexec, this helps novice cgi scripters avoid putt= ing passwords in the script. b) We also set the environment variable PGDATABASE to LOGNAME= =20 so people can just run psql w/o prarams and get to their = database 3) Allow remote users to connect to a particular database with a password 4) Allow superuser (postgres) to attach to any database 5) Deny everything else. A related question: Right now we give a user full privledges to the database, named after the u= ser by=20 1) creating the user with CREATEDB=20 2) Give the user the right to connect to the database dummy 3) creating a database as that user 4) taking away the users rights to CREATEDB Is there a less kludgy way? GRANTing ALL on a database? Changing ownership of a database? ###################################################################### # line below removes almost all security any local user can connect as # any user including the postgres database superuser UNCOMMENT WITH # CAUTION #local all trust # kludge to allow users to connect to server to create database # w/o giving everyone access to postgres account local dummy password dummy_users.list # Users can locally connect to databases named after their OS login # names For example, felicia can connect to a database called felicia # but not to a database called john. Requires apt-get install ident2 # configure #connect database IP number mask auth meth auth arg local sameuser ident sameuser host sameuser 127.0.0.1 255.0.0.0 ident sameuser # If above method does not apply (felicia tries to connect # to database john) method below will be tried and user # will be asked for a password that doesn't exist and # there will be FAILURE (a good thing) #connect database security password file local utec md5 utec_local_users.list # Give admin types ability to connect to ALL databases locally # Get list of admins from FILE: admin_users.list in DIR $PGDATA # # Admin user must have password in database system catalog # table pg_shadow. See docs for ALTER USER to set password # entry in pg_shadow # # Only super user postgres has automatic privs (grants) to # objects in database. #connect database security method file with users local all password admin_users.list #LOCAL ACCESS WITH PASSWORD # ---if user is in password file for database # ---and has password in file (bad) # or in pg_shadow table via ALTER USER #REMOTE_ACCESS # It is possible to allow access only from certain IP numbers #connect database IP num mask to xor=20=20 host acarvalh 0.0.0.0 0.0.0.0 md5 acarvalh_users.list host dsiegal 0.0.0.0 0.0.0.0 md5 dsiegal_users.list host omacneil 0.0.0.0 0.0.0.0 md5 omacneil_users.list host felicia 0.0.0.0 0.0.0.0 md5 felicia_users.list host john 0.0.0.0 0.0.0.0 md5 john_users.list host calendarlctc 0.0.0.0 0.0.0.0 md5 calendarlctc_users.list host utec 0.0.0.0 0.0.0.0 md5 utec_remote_users.list # reject all connections from all hosts not granted above host all 0.0.0.0 0.0.0.0 reject ------=_NextPart_000_005D_01C2915E.71F01CF0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
It would be great if somebody could revi= ew our=20 pg_hha.conf file below to see if it does what we want it to, no more and no= =20 less.
 
 
The goals for our pg_hba.conf file=20 are:
 
1) In an emergency allow somebody with= =20 operatating
   system root privs acce= ss to all=20 the databases with full privs.
 
2) Allow local shell users to conne= ct to=20 databases named after
   themselves wit = no authentification.&nb= sp; =20
           = a) As=20 we run suexec, this helps novice cgi scripters avoid putting<= /DIV>
   =20             password= s in=20 the script.
           = =20 b)  We also set the environment variable PGDATABASE to LOGNAME=20
       =20           so people can just run ps= ql=20 w/o prarams and get to their database
 
3) Allow remote users to connect to a part= icular=20 database with a password
 
4) Allow superuser (postgres) to attach to= any=20 database
 
5) Deny everything else.
 
A related question:
 
Right now we give a user full privledges t= o the=20 database, named after the user by
 
1) creating the user with CREATEDB =
2) Give the user the right to connect to t= he=20 database dummy
3) creating a database as that user=
4) taking away the users rights to=20 CREATEDB
 
Is there a less kludgy way?
 
GRANTing ALL on a database?
 
Changing ownership of a database?
 
 
 
##################################################################= ####
 
# line below removes almost all security= any=20 local user can connect as
# any user including the postgres database=20 superuser UNCOMMENT WITH
# CAUTION
 
#local         =20 all            = =20 trust
 
# kludge to allow users to connect to se= rver to=20 create database
# w/o giving everyone access to postgres=20 account
local          = ;=20 dummy          =20 password        dummy_users.list
<= /DIV>
 
# Users can locally connect to databases= named=20 after their OS login
# names For example, felicia can connect to a datab= ase=20 called felicia
# but not to a database called john. Requires apt-get ins= tall=20 ident2
# configure
 
#connect   =20 database    IP number   =20 mask       auth meth auth=20 arg
local      =20 sameuser           &= nbsp;           &nbs= p;   =20 ident    =20 sameuser
host       =20 sameuser    127.0.0.1   255.0.0.0  =20 ident     sameuser
 
# If above method does not apply (felici= a tries=20 to connect
# to database john) method below will be tried and user
# = will=20 be asked for a password that doesn't exist and
# there will be FAILURE (= a=20 good thing)
 
#connect  =20 database     security      pas= sword=20 file
local     =20 utec        =20 md5          =20 utec_local_users.list
 
# Give admin types ability to connect to= ALL=20 databases locally
# Get list of admins from FILE: admin_users.list in DI= R=20 $PGDATA
#
# Admin user must have password in database system catalog<= BR>#=20 table pg_shadow. See docs for ALTER USER to set password
# entry in=20 pg_shadow
#
# Only super user postgres has automatic privs (grants)= =20 to
# objects in database.
 
=
#connect       = =20 database        security method &nb= sp;=20 file with=20 users
local          = =20 all            = =20 password         =20 admin_users.list
 
#LOCAL ACCESS WITH PASSWORD
# ---if u= ser is in=20 password file for database
# ---and has password in file=20 (bad)
#    or in pg_shadow table via ALTER USER
 
=
#REMOTE_ACCESS
 
# It is possible to allow access only fr= om=20 certain IP numbers
 
#connect =20 database      IP num    mask to=20 xor 
host     =20 acarvalh      0.0.0.0  =20 0.0.0.0     md5 acarvalh_users.list
host&n= bsp;    =20 dsiegal       0.0.0.0  =20 0.0.0.0     md5 dsiegal_users.list
host&nb= sp;    =20 omacneil      0.0.0.0  =20 0.0.0.0     md5 omacneil_users.list
host&n= bsp;    =20 felicia       0.0.0.0  =20 0.0.0.0     md5 felicia_users.list
host&nb= sp;    =20 john          0.0.0.0 &nb= sp;=20 0.0.0.0     md5 john_users.list
host =     =20 calendarlctc  0.0.0.0   0.0.0.0     = ;md5=20 calendarlctc_users.list
host     =20 utec          0.0.0.0 &nb= sp;=20 0.0.0.0     md5 utec_remote_users.list=
 
# reject all connections from all hosts = not=20 granted above
host   =20 all            = =20 0.0.0.0      =20 0.0.0.0      reject
------=_NextPart_000_005D_01C2915E.71F01CF0--