|
Cookbook /
AuthPunBBSummary: Use PunBB/FluxBB user authentication for PmWiki
Version: 2009-JAN-30
Prerequisites:
Status: Draft
Maintainer: Kory Roberts
Questions answered by this recipeHow do I use a PunBB/FluxBB 1.3 database to authenticate users for PmWiki? Prior KnowledgeIf needed, please review the following topics before attempting to install and use this recipe. Limitations
Testing
StepsStep 1 - Downloads
Step 2 - ConfigEdit your config.php file to use all of this stuff! The following can be used as a template:
# optional, but handy for limiting groups
$GroupPattern = '(?:Site|SiteAdmin|PmWiki|Main|Profiles)';
# connection settings for database authentication
$Databases['punbb_db'] = array(
'driver' => 'mysql', # what type of database?
'hostname' => 'localhost', # what hostname? ...localhost should work for most people
'database' => 'punbb_db', # what database?
'username' => 'punbb_db_user', # what username?
'password' => 'punbb_db_password'); # what password?
# path to adodb lite database library
$ADOdbLocation = '$FarmD/cookbook/adodb_lite/';
# variables used in authuserdbase
$AuthUserFunctions['mysql'] = 'AuthUserDatabase'; # should match driver from above
$AuthUser['mysql'] = true; # should match driver from above
$AUDBaseTable['database'] = 'punbb_db'; # should match array from above
$AUDBaseTable['user_table'] = 'punbb_users'; # what table for punbb users? (prefix punbb_ needs to match setup)
$AUDBaseTable['user_field'] = 'username'; # should be username for standard setup
$AUDBaseTable['pw_field'] = 'password'; # should be password for standard setup
$AUDBaseTable['salt_field'] = 'salt'; # should be salt for standard setup
$AUDBaseTable['encrypt_f'] = 'punbbpass'; # should match function name below
# function required for authentication using punbb database
function punbbpass($pasw)
{
global $DB, $AUDBaseTable;
$dbase = $AUDBaseTable['database'];
$sf = $AUDBaseTable['salt_field'];
$ut = $AUDBaseTable['user_table'];
$uf = $AUDBaseTable['user_field'];
$id = AUD_Safe($_POST['authid']);
$out = ADOdbConnect($dbase);
if ($out !== TRUE) die($out);
$result = $DB[$dbase]->Execute("SELECT " . $sf . " FROM " . $ut . " WHERE " . $uf . "=" . $id);
return sha1($result->fields[$sf] . sha1($pasw));
}
# scripts used for database authentication
include_once ("$FarmD/cookbook/adodb-connect.php");
include_once ("$FarmD/cookbook/authuserdbase.php");
include_once("$FarmD/scripts/authuser.php");
$EnablePostAuthorRequired = 1; # require authors to provide a name
$Author = $AuthId; # force author name to match login name
Step 3 - ApplyPassword protect pages. Typical use will involve appending ?action=attr to a page (or group) and using id:*. This will allow any authenticated user to edit, view, or change attributes for a particular page or group. Limit who can edit pages of the Main group to users registered on your PunBB forum:
Limit who can edit a particular page (SomePage.html) to a particular registered user (Alice) on your PunBB forum:
See AlsoContributors
Comments
User notes?: If you use, used or reviewed this recipe, you can add your name. The following format is recognized:
* (+) Optional positive comment. Name, date * (-) Optional negative comment. Name, date These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |