If you wish to have greater control over the structure and interface to your database, you can create your own database functions to use with the library.
All the functions listed here are required and must be specified in the configuration section of the file.
Throughout any of these functions, you can make use of relevant configuration variables (for example, nonce expire times, etc). Just be sure to include the global $CONFIG array.
The functions here will be refereed by their name in the configuration.
Called using:
function($user)
This function is called whenever the system needs to retrieve a user's valid hash. It should return a hash on success or false on any failure. The database connection may not be present, so it is wise to verify it and connect if need be.
These functions take no arguments and are called at the start and stop of the authentication process. They should return database handles to be used by the other interface functions or false on failure.
This function handles the nonce functions of the Digest authentication. If you are running basic authentication, insert nullFunc as the function name to disable the function.
It is called via:
function($mode, $nonce, $nc)
$mode specifies how the function will proceed, and will be either 1 2 or 3. Mode 1 is inserting a new nonce. The nonce is generated, but only needs to be inserted into the database.
Mode 2 checks the validity of a nonce/nc value.
Mode 3 expires a nonce.
With these functions, they should return true on success or false on failure.
If you are logging the authentications, this function should insert a log entry into the database. IT is called via:
function($ip, $result, $user)
$result is the outcome of this auth. 0 is success, 1 is failure, 3 is blacklisted. $user is only passed on successful page loads.
This function checks to see if a user has too many recent failed auths in the log. It is called via:
function($ip)
Where IP is the ip of the user. It should return true on success or false if the user auth should fail.