auth:mysql_postnuke
« MySQL Authentification Backend
User authentication with Postnuke
Changes to mysql.conf.php
/* Options to configure database access. You need to set up this * options carefully, otherwise you won't be able to access you * database. */ $conf['auth']['mysql']['server'] = 'your_server'; $conf['auth']['mysql']['user'] = 'your_db_user'; $conf['auth']['mysql']['password'] = 'your_db_pass'; $conf['auth']['mysql']['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['auth']['mysql']['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['auth']['mysql']['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['auth']['mysql']['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['auth']['mysql']['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['auth']['mysql']['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['auth']['mysql']['FilterLogin'] = "u.pn_uname LIKE '%{user}'"; $conf['auth']['mysql']['FilterName'] = "u.pn_name LIKE '%{name}'"; $conf['auth']['mysql']['FilterEmail'] = "u.pn_email LIKE '%{email}'"; $conf['auth']['mysql']['FilterGroup'] = "g.pn_name LIKE '%{group}'"; $conf['auth']['mysql']['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['auth']['mysql']['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['auth']['mysql']['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['auth']['mysql']['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['auth']['mysql']['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['auth']['mysql']['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['auth']['mysql']['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['auth']['mysql']['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['auth']['mysql']['updateUser'] = "UPDATE nuke_users SET"; $conf['auth']['mysql']['UpdateLogin'] = "pn_uname='%{user}'"; $conf['auth']['mysql']['UpdatePass'] = "pn_pass='%{pass}'"; $conf['auth']['mysql']['UpdateEmail'] = "pn_email='%{email}'"; $conf['auth']['mysql']['UpdateName'] = "pn_name='%{name}'"; $conf['auth']['mysql']['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['auth']['mysql']['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['auth']['mysql']['getGroupID'] = "SELECT pn_gid AS id FROM nuke_groups WHERE pn_name='%{group}'";
auth/mysql_postnuke.txt · Last modified: 2011-03-22 17:32 by Aleksandr