PostgreSQL Authentication Module

Min S. Kim <minskim@bawi.org>

1 June 2004


This document explains how to install and use AuthPG.

1. Introduction

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.

2. Requirements

This module is tested with Apache-1.3.29 and PostgreSQL-7.3.2.

3. Installation

See INSTALL.

4. Usage

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.

4.1 .htaccess

Apache doesn't recognize .htaccess at default. You must edit httpd.conf to enable .htaccess. Open httpd.conf and you will find the line <Directory /any/path>. Between <Directory /any/path> and </Directory> 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.

4.2 httpd.conf

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>


Since 19 Jul 1998
Counter
minskim@bawi.org