#include <infodrom.style>
#include <debian.style>

<page title="Debian Tips">

<h1 align=center>Usage of mod_auth_mysql</h1>

<p>The Apache module mod_auth_mysql provides easy web authentication
against a MySQL database.  No password files have to be used anymore
and as a bonus authentication can be shared with other web
applications such as Mantis, Cacti, Bugzilla, phpGroupWare etc.</p>

<p>In Debian however, the package <a
href="http://packages.debian.org/libapache2-mod-auth-mysql">\
libapache2-mod-auth-mysql</a> has been removed from <a
href="http://www.debian.org/releases/etch/">etch</a>.  It is well
maintained in sid, though, and compiles fine on etch and is useable as
well.</p>

<p>When the included module mod_auth_mysql is enabled authentication
via BasicAuth (and .htaccess) may refer to information stored in an
MySQL database.  Authentication configuration looks like:</p>

<p><pre>
   AuthType Basic

   AuthBasicAuthoritative Off
   AuthUserFile /dev/null

   AuthMySQL On
   AuthMySQL_Socket /var/run/mysqld/mysqld.sock
   AuthMySQL_User db_user
   AuthMySQL_Password db_pass
   AuthMySQL_DB db_name
   AuthMySQL_Password_Table db_table
   AuthMySQL_Username_Field db_username
   AuthMySQL_Password_Field db_password
   AuthMySQL_Encryption_Types PHP_MD5

   &lt;Limit GET POST PUT HEAD&gt;
   require valid-user
   &lt;/Limit&gt
</pre></p>

<p>The hostname (even localhost) may be specified instead of the
socket.  There are more encryption types supported (see the
documentation).  This module supports a large number of more
configuration options.</p>

<p>However, its documentation usually lacks the note that regular
BasicAuth needs to be turned off and its password file nullified.
Both lines are important, otherwise authentication will not work and
also result in a server error.  For some reason, the basic auth
routine tries to open a password file regardless of its non-use.</p>

<p>The error messages accompanying the lack of a
<code>AuthUserFile</code> setting looks like:</p>

<p><pre>
   [Thu Nov 01 20:12:19 2007] [error] Internal error: pcfg_openfile() called with NULL filename
   [Thu Nov 01 20:12:19 2007] [error] [client 127.0.0.1] (9)Bad file descriptor: Could not open password file: (null)
</pre></p>

</page>

# Local variables:
# mode: indented-text
# end:
