It's easy. For example, restrict access to sncatupdate.cgi
/usr/local/apache/bin/htpasswd -c /usr/local/apache/conf/passwd sncat
<LocationMatch "sncatupdate.cgi"> AuthType Basic AuthName "Update SN catalogue" AuthUserFile /usr/local/apache/conf/passwd Require user sncat </LocationMatch>
createuser -SDRI -e -P sncat
grant all on sn.galaxies to sncat; grant all on sn.sn to sncat; grant all on sn.map to sncat;
In sncatupdate.cgi use $ENV{REMOTE_USER} и $ENV{REMOTE_ADDR} to setup connection to PostgreSQL.
my $dbh = DBI->connect($DSN,$ENV{REMOTE_USER}, 'NULL');