PostgreSQL Authentication Module (AuthPG) enables Apache to authenticate users with the information stored in PostgreSQL database. This module gets a username and password pair in the standard way or from a cookie, and you can choose your preferred method.
This module is tested with Apache-1.3.29 and PostgreSQL-7.3.2.
There are two ways to use mod_auth_pg. The one is to make .htaccess file in the directory which requires user authentication, and the other is to edit httpd.conf.
Apache doesn't recognize .htaccess at default. You must edit
httpd.conf to enable .htaccess. Open httpd.conf and you will find
<Directory /any/path>. Between
<Directory /any/path> and
there is a line which starts with AllowOverride. The value of this
item should contain AuthConfig or All. Edit and save it. Now restart
Apache or give the signal with kill to reload httpd.conf.
Open .htaccess in the directory requiring user authentication, and write whatever directives you need.
AuthName my_auth AuthType Basic AuthPGHost my.database.server AuthPGDatabase my_db AuthPGUserTable user_table require valid-user
If you specify the name of host after AuthPGHost directive, Apache
will try to connect to PostgreSQL using internet domain socket, which
means you should run postmaster with
-i option, and edit
configuration file to allow this type of access. When omit AuthPGHost
directive, postmaster and httpd should run on the same machine.
Consult mod_auth_pg.html for the usage of each directive.
Specify the directory requiring user authentication using
<Directory /my/directory> in httpd.conf. The
directives between opening and closing Directory tag are the same ones
as in .htaccess. If you want user authentication in /my/secret, insert
the followings into httpd.conf
<Directory /my/srcret> (the same directives as in .htaccess) </Directory>