DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:authmysql:unb2

Yet Another Unclassified News Board

Configuration for authMySQL Auth plugin to connect to UNB, which let's do:

  • Only basic authentication
  • Only wanted members of certain groups are able to log into wiki
  • No user modification/adding. You can maintain your users via UNB, via the DokuWiki interface is not implemented here.

Differences with similar MySQL auth config unb: capitalization of table names and additional statement for group membership checking.

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.

Configuration

Use the Config Manager or add it to conf/local.protected.php to store the config protected.

conf/local.protected.php
<?php
/**
 * UNB configuration for MySQL Auth Plugin
 * See https://www.dokuwiki.org/plugin:authmysql:unb2 for details and explanation
 */
 
// Settings
$conf['useacl']      = 1;             // ACL must be enabled
$conf['authtype']    = 'mysql';       // Activates MySQL auth plugin
$conf['passcrypt']   = 'kmd5';        // Set password hashing method to UNB's default
$conf['superuser']   = 'SomeUser';    // Username of Admin in UNB
 
/*
// Let any member of forums log into wiki.
$conf['plugin']['authmysql']['checkPass']   = "SELECT Password AS pass
                                               FROM unb1_Users
                                               WHERE Name='%{user}'";
*/
 
// Let only certain groups log into the wiki
$conf['plugin']['authmysql']['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";
 
// Returns table with info for one user:
$conf['plugin']['authmysql']['getUserInfo'] = "SELECT Password AS pass, Name AS name, EMail AS mail
                                               FROM unb1_Users
                                               WHERE Name='%{user}'";
 
// Get all groups user is a member of:
$conf['plugin']['authmysql']['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}'";
 
// This statement should return a table containing all user login names
$conf['plugin']['authmysql']['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['plugin']['authmysql']['FilterLogin'] = "u.Name LIKE '%{user}'";
$conf['plugin']['authmysql']['FilterName']  = "u.Name LIKE '%{name}'";
$conf['plugin']['authmysql']['FilterEmail'] = "u.Email LIKE '%{email}'";
$conf['plugin']['authmysql']['FilterGroup'] = "gn.Name LIKE '%{group}'";
$conf['plugin']['authmysql']['SortOrder']   = "ORDER BY u.Name";
 
// This statement should return the database index of a given user name.
$conf['plugin']['authmysql']['getUserID']   = "SELECT ID AS id
                                               FROM unb1_Users
                                               WHERE Name='%{user}'";
plugin/authmysql/unb2.txt · Last modified: 2013-02-10 00:45 by Klap-in