DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:authmysql:postnuke

Postnuke

Configuration for authMySQL Auth plugin to authenticate with Postnuke, which let's do:

  • User authentication
  • User modification/adding/deleting.

Configuration

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

conf/local.protected.php
/**
 * Postnuke configuration for MySQL Auth Plugin
 * See https://www.dokuwiki.org/auth:mysql:postnuke for details and explanation
 */
 
/**
 * Options to configure database access. You need to set up this
 * options carefully, otherwise you won't be able to access you
 * database.
 */
$conf['plugin']['authmysql']['server']   = 'your_server';
$conf['plugin']['authmysql']['user']     = 'your_db_user';
$conf['plugin']['authmysql']['password'] = 'your_db_pass';
$conf['plugin']['authmysql']['database'] = 'your_postnuke';
 
/* Multiple table operations will be protected by locks. This array tells
 * the module which tables to lock. If you use any aliases for table names
 * these array must also contain these aliases. Any unnamed alias will cause
 * a warning during operation. See the example below.
 */
$conf['plugin']['authmysql']['TablesToLock']= array("nuke_users", "nuke_users AS u","nuke_groups",
"nuke_groups AS g", "nuke_group_membership", "nuke_group_membership AS ug");
 
/***********************************************************************/
/*       Basic SQL statements for user authentication (required)       */
/***********************************************************************/
 
/* This statement is used to grant or deny access to the wiki. The result
 * should be a table with exact one line containing at least the password
 * of the user. If the result table is empty or contains more than one
 * row, access will be denied.
 *
 * The module access the password as 'pass' so a alias might be necessary.
 *
 * Following patters will be replaced:
 *   %{user}	user name
 *   %{pass}	encrypted or clear text password (depends on 'encryptPass')
 *   %{dgroup}	default group name 
 */
$conf['plugin']['authmysql']['checkPass']   = "SELECT pn_pass AS pass
                                               FROM nuke_users
                                               WHERE pn_uname='%{user}'";
 
 
/* This statement should return a table with exact one row containing
 * information about one user. The field needed are:
 * 'pass'  containing the encrypted or clear text password
 * 'name'  the user's full name
 * 'mail'  the user's email address
 *
 * Keep in mind that DokuWiki will access this information through the
 * names listed above so aliases might be necessary.
 *
 * Following patters will be replaced:
 *   %{user}	user name
 */
$conf['plugin']['authmysql']['getUserInfo'] = "SELECT pn_pass AS pass, CONCAT(pn_uname,' = ',pn_name) AS name, pn_email AS mail
                                               FROM nuke_users
                                               WHERE pn_uname='%{user}'";
 
/* This statement is used to get all groups a user is member of. The
 * result should be a table containing all groups the given user is
 * member of. The module access the group name as 'group' so a alias
 * might be necessary.
 *
 * Following patters will be replaced:
 *   %{user}	user name
 */
$conf['plugin']['authmysql']['getGroups']   = "SELECT g.pn_name as `group`
                                               FROM nuke_groups g, nuke_users u, nuke_group_membership ug
                                               WHERE u.pn_uid = ug.pn_uid
                                                 AND g.pn_gid = ug.pn_gid
                                                 AND u.pn_uname='%{user}'";
 
/***********************************************************************/
/*      Additional minimum SQL statements to use the user manager      */
/***********************************************************************/
 
/* This statement should return a table containing all user login names
 * that meet certain filter criteria. The filter expressions will be added
 * case dependent by the module. At the end a sort expression will be added.
 * Important is that this list contains no double entries for a user. Each
 * user name is only allowed once in the table.
 *
 * The login name will be accessed as 'user' to a alias might be necessary.
 * No patterns will be replaced in this statement but following patters
 * will be replaced in the filter expressions:
 *   %{user}	in FilterLogin  user's login name
 *   %{name}	in FilterName   user's full name
 *   %{email}	in FilterEmail  user's email address
 *   %{group}	in FilterGroup  group name
 */
$conf['plugin']['authmysql']['getUsers']    = "SELECT DISTINCT pn_uname AS user
                                               FROM nuke_users AS u 
                                               LEFT JOIN nuke_group_membership AS ug ON u.pn_uid=ug.pn_uid
                                               LEFT JOIN nuke_groups AS g ON ug.pn_gid=g.pn_gid";
$conf['plugin']['authmysql']['FilterLogin'] = "u.pn_uname LIKE '%{user}'";
$conf['plugin']['authmysql']['FilterName']  = "u.pn_name LIKE '%{name}'";
$conf['plugin']['authmysql']['FilterEmail'] = "u.pn_email LIKE '%{email}'";
$conf['plugin']['authmysql']['FilterGroup'] = "g.pn_name LIKE '%{group}'";
$conf['plugin']['authmysql']['SortOrder']   = "ORDER BY u.pn_uname";
 
/***********************************************************************/
/*   Additional SQL statements to add new users with the user manager  */
/***********************************************************************/
 
/* This statement should add a user to the database. Minimum information
 * to store are: login name, password, email address and full name.
 *
 * Following patterns will be replaced:
 *   %{user}	user's login name
 *   %{pass}	password (encrypted or clear text, depends on 'encryptPass')
 *   %{email}	email address
 *   %{name}	user's full name
 */ 
$conf['plugin']['authmysql']['addUser']     = "INSERT INTO nuke_users
                                               (pn_uname, pn_pass, pn_email, pn_name)
                                               VALUES ('%{user}', '%{pass}', '%{email}','%{name}')";
 
 
/* This statement should add a group to the database.
 * Following patterns will be replaced:
 *   %{group}	group name
 */
$conf['plugin']['authmysql']['addGroup']    = "INSERT INTO nuke_groups (pn_name)
                                               VALUES ('%{group}')";
 
/* This statement should connect a user to a group (a user become member
 * of that group).
 * Following patterns will be replaced:
 *   %{user}	user's login name
 *   %{uid}		id of a user dataset
 *   %{group}	group name
 *   %{gid}		id of a group dataset
 */
$conf['plugin']['authmysql']['addUserGroup']= "INSERT INTO nuke_group_membership (pn_uid, pn_gid)
                                               VALUES ('%{uid}', '%{gid}')";
 
/* This statement should remove a group from the database.
 * Following patterns will be replaced:
 *   %{group}	group name
 *   %{gid}		id of a group dataset
 */
$conf['plugin']['authmysql']['delGroup']    = "DELETE FROM nuke_groups
                                               WHERE pn_gid='%{gid}'";
 
/* This statement should return the database index of a given user name.
 * The module will access the index with the name 'id' so a alias might be
 * necessary.
 * following patters will be replaced:
 *   %{user}	user name 
 */
$conf['plugin']['authmysql']['getUserID']   = "SELECT pn_uid AS id
                                               FROM nuke_users
                                               WHERE pn_uname='%{user}'";
 
/***********************************************************************/
/*   Additional SQL statements to delete users with the user manager   */
/***********************************************************************/
 
/* This statement should remove a user from the database.
 * Following patterns will be replaced:
 *   %{user}	user's login name
 *   %{uid}		id of a user dataset
 */
$conf['plugin']['authmysql']['delUser']     = "DELETE FROM nuke_users
                                               WHERE pn_uid='%{uid}'";
 
/* This statement should remove all connections from a user to any group
 * (a user quits membership of all groups).
 * Following patterns will be replaced:
 *   %{uid}		id of a user dataset
 */
$conf['plugin']['authmysql']['delUserRefs'] = "DELETE FROM nuke_group_membership
                                               WHERE pn_uid='%{uid}'";
 
/***********************************************************************/
/*   Additional SQL statements to modify users with the user manager   */
/***********************************************************************/
 
/* This statements should modify a user entry in the database. The
 * statements UpdateLogin, UpdatePass, UpdateEmail and UpdateName will be
 * added to updateUser on demand. Only changed parameters will be used.
 *
 * Following patterns will be replaced:
 *   %{user}	user's login name
 *   %{pass}	password (encrypted or clear text, depends on 'encryptPass')
 *   %{email}	email address
 *   %{name}	user's full name
 *   %{uid}     user id that should be updated
 */ 
$conf['plugin']['authmysql']['updateUser']  = "UPDATE nuke_users SET";
$conf['plugin']['authmysql']['UpdateLogin'] = "pn_uname='%{user}'";
$conf['plugin']['authmysql']['UpdatePass']  = "pn_pass='%{pass}'";
$conf['plugin']['authmysql']['UpdateEmail'] = "pn_email='%{email}'";
$conf['plugin']['authmysql']['UpdateName']  = "pn_name='%{name}'";
$conf['plugin']['authmysql']['UpdateTarget']= "WHERE pn_uid=%{uid}";
 
/* This statement should remove a single connection from a user to a
 * group (a user quits membership of that group).
 *
 * Following patterns will be replaced:
 *   %{user}	user's login name
 *   %{uid}		id of a user dataset
 *   %{group}	group name
 *   %{gid}		id of a group dataset
 */
$conf['plugin']['authmysql']['delUserGroup']= "DELETE FROM nuke_group_membership
                                               WHERE pn_uid='%{uid}'
                                                 AND pn_gid='%{gid}'";
 
/* This statement should return the database index of a given group name.
 * The module will access the index with the name 'id' so a alias might
 * be necessary.
 *
 * Following patters will be replaced:
 *   %{group}	group name 
 */
$conf['plugin']['authmysql']['getGroupID']  = "SELECT pn_gid AS id
                                               FROM nuke_groups
                                               WHERE pn_name='%{group}'";
plugin/authmysql/postnuke.txt · Last modified: 2013-03-16 16:33 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki