DokuWiki

It's better when it's simple

User Tools

Site Tools


Sidebar

Translations of this page?:

Learn about DokuWiki

Advanced Use

Corporate Use

Our Community


Follow us on Facebook, Twitter and other social networks.

auth:mysql_unb

« MySQL Authentification Backend

Unclassified News Board

Please forgive me if this code doesn't work for you, it was my first real attempt at working with MySQL. It works for me, and I am confident that it is not going to nuke your DB or anything.

Tested on UNB 20080531-dev, though I think it will work with any version that supports AUTH via MySQL.

Includes only the basic auth. It is assumed you will continue to maintain your users via UNB, and not the DokuWiki interface.

Please note that you will either have to change the password type from UNB's custom KMD5 to regular ol' MD5 (as discussed here), or work out a way to stuff UNB's KMD5 into DokuWiki. I opted for the former: it is easy to do however will require all your UNB users to create new passwords before DokuWiki will recognize them.

// Grant or Deny access to the wiki:
 
$conf['auth']['mysql']['checkPass']   = "SELECT Password AS pass
                                         FROM unb_users
                                         WHERE Name='%{user}'";
 
// Returns table with info for one user:
 
$conf['auth']['mysql']['getUserInfo'] = "SELECT Password AS pass, Name AS name, EMail AS mail
                                         FROM unb_users
                                         WHERE Name='%{user}'";
 
// Get all groups user is a member of:
 
$conf['auth']['mysql']['getGroups']   = "SELECT gn.Name as `group`
					FROM unb_groupmembers gm, unb_users u, unb_groupnames gn
					WHERE u.ID = gm.User
					AND gn.ID = gm.Group
					AND u.Name='%{user}'";
 
// This statement should return a table containing all user login names
 
$conf['auth']['mysql']['getUsers']    = "SELECT DISTINCT u.Name AS 'user'
                                         FROM unb_users AS u 
                                         LEFT JOIN unb_groupmembers AS gm ON u.ID=gm.User
                                         LEFT JOIN unb_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";
 
// This statement should return the database index of a given user name.
 
$conf['auth']['mysql']['getUserID']   = "SELECT ID AS id
                                         FROM unb_users
                                         WHERE Name='%{user}'";

NFGman 2008/08/10 10:29

auth/mysql_unb.txt · Last modified: 2011-03-22 17:24 by Aleksandr