« MySQL Authentification Backend
Yet Another Unclassified News Board
So I tried the other UNB example and I could never get it to work. I'm using the most recent version of DokuWiki (2008-05-05), MySQL 5.0.51, and UNB 1.6.4.full. I did have an extra requirement though of I only wanted members of certain groups to be able to log into the wiki in order to make edits.
So here is a list of all of the changes I've had to make in order to hack this together. I don't think I missed anything, but you can always email me (jon at purplefoot dot com) if you have any problems and I'll see if I can help (assuming it's the same versions since it's all I have ).
If I have to change anything else I'll try to remember to come back and list it here as well.
conf/local.php:
$conf['useacl'] = 1; // Must be enabled $conf['autopasswd'] = 0; // Must be disabled $conf['authtype'] = 'mysql'; // Should be obvious $conf['passcrypt'] = 'md5'; // I'm actually ignoring this... see farther down. :) $conf['superuser'] = 'SomeUser'; // Username of Admin in UNB $conf['disableactions'] = 'register,resendpwd'; @include(DOKU_CONF.'mysql.conf.php');
conf/mysql.conf.php:
I have two selects here for checkPass. The first one would let any member of forums log into the wiki. The rest of my file is the same as the example.
/* $conf['auth']['mysql']['checkPass'] = "SELECT Password AS pass FROM unb1_Users WHERE Name='%{user}'"; */ $conf['auth']['mysql']['checkPass'] = "SELECT Password AS pass FROM unb1_Users u WHERE Name='%{user}' AND (SELECT COUNT(1) AS level FROM unb1_GroupMembers gm WHERE User = u.ID AND gm.Group IN (3,4)) > 0"; $conf['auth']['mysql']['getUserInfo'] = "SELECT Password AS pass, Name AS name, EMail AS mail FROM unb1_Users WHERE Name='%{user}'"; $conf['auth']['mysql']['getGroups'] = "SELECT gn.Name as `group` FROM unb1_GroupMembers gm, unb1_Users u, unb1_GroupNames gn WHERE u.ID = gm.User AND gn.ID = gm.Group AND u.Name='%{user}'"; $conf['auth']['mysql']['getUsers'] = "SELECT DISTINCT u.Name AS 'user' FROM unb1_Users AS u LEFT JOIN unb1_GroupMembers AS gm ON u.ID=gm.User LEFT JOIN unb1_GroupNames AS gn ON gm.Group=gn.ID"; $conf['auth']['mysql']['FilterLogin'] = "u.Name LIKE '%{user}'"; $conf['auth']['mysql']['FilterName'] = "u.Name LIKE '%{name}'"; $conf['auth']['mysql']['FilterEmail'] = "u.Email LIKE '%{email}'"; $conf['auth']['mysql']['FilterGroup'] = "gn.Name LIKE '%{group}'"; $conf['auth']['mysql']['SortOrder'] = "ORDER BY u.Name"; $conf['auth']['mysql']['getUserID'] = "SELECT ID AS id FROM unb1_Users WHERE Name='%{user}'";
inc/auth.php
In function auth_cryptPassword I added this case:
case 'kmd5': $key = substr($salt, 16, 2); $hash1 = strtolower(md5($key . md5($clear))); $hash2 = substr($hash1, 0, 16) . $key . substr($hash1, 16); return $hash2;
And in function auth_verifyPassword I added this elseif:
}elseif($len == 34){ $method = 'kmd5'; $salt = $crypt;