1<?php 2/* 3 * This is an example configuration for the mysql auth module. 4 * 5 * This SQL statements are optimized for following table structure. 6 * If you use a different one you have to change them accordingly. 7 * See comments of every statement for details. 8 * 9 * TABLE users 10 * uid login pass firstname lastname email 11 * 12 * TABLE groups 13 * gid name 14 * 15 * TABLE usergroup 16 * uid gid 17 * 18 * To use this configuration you have to copy them to local.php 19 * or at least include this file in local.php. 20 */ 21 22/* Options to configure database access. You need to set up this 23 * options carefully, otherwise you won't be able to access you 24 * database. 25 */ 26$conf['auth']['mysql']['server'] = ''; 27$conf['auth']['mysql']['user'] = ''; 28$conf['auth']['mysql']['password'] = ''; 29$conf['auth']['mysql']['database'] = ''; 30 31/* Normally password encryptionis done by DokuWiki (recommended) but for 32 * some reasons it might be usefull to let the database do the encryption. 33 * Set 'encryptPass' to '1' and the cleartext password is forwarded to 34 * the database, otherwise the encrypted one. 35 */ 36$conf['auth']['mysql']['encryptPass'] = 0; 37 38/* Multiple table operations will be protected by locks. This array tolds 39 * the module which tables to lock. If you use any aliases for table names 40 * these array must also contain these aliases. Any unamed alias will cause 41 * a warning during operation. See the example below. 42 */ 43$conf['auth']['mysql']['TablesToLock']= array("users", "users AS u","groups", "groups AS g", "usergroup", "usergroup AS ug"); 44 45/* This statement should return the database index of a given user name. 46 * The module will access the index with the name 'id' so a alias might be 47 * necessary. 48 * following patters will be replaced: 49 * %{user} user name 50 */ 51$conf['auth']['mysql']['getUserID'] = "SELECT uid AS id FROM users WHERE login='%{user}'"; 52 53/* This statement should return the database index of a given group name. 54 * The module will access the index with the name 'id' so a alias might be 55 * necessary. 56 * following patters will be replaced: 57 * %{group} group name 58 */ 59$conf['auth']['mysql']['getGroupID'] = "SELECT gid AS id FROM groups WHERE name='%{group}'"; 60 61/* This statement is used to grant or deny access to the wiki. The result should 62 * be a table with exact one line containing at least the password of the user. 63 * If the result table is empty or contains more than one row, access will be denied. 64 * The module access the password as 'pass' so a alias might be necessary. 65 * following patters will be replaced: 66 * %{user} user name 67 * %{pass} encrypted or clear text password (depends on 'encryptPass') 68 * %{dgroup} default group name 69 */ 70$conf['auth']['mysql']['checkPass'] = "SELECT pass 71 FROM usergroup AS ug 72 JOIN users AS u ON u.uid=ug.uid 73 JOIN groups AS g ON g.gid=ug.gid 74 WHERE login='%{user}' 75 AND name='%{dgroup}'"; 76 77/* This statement is used to get all groups a user is member of. The result should 78 * be a table containing all groups the given user is member of. The module access 79 * the group name as 'group' so a alias might be nessecary. 80 * following patters will be replaced: 81 * %{user} user name 82 */ 83$conf['auth']['mysql']['getGroups'] = "SELECT name as `group` 84 FROM groups g, users u, usergroup ug 85 WHERE u.uid = ug.uid 86 AND g.gid = ug.gid 87 AND u.login='%{user}'"; 88 89/* This statement should return a table with exact one row containing information 90 * about one user. The field needed are: 91 * 'pass' containing the encrypted or clear text password 92 * 'name' the user's full name 93 * 'mail' the user's email address 94 * Keep in mind that Dokuwiki will access thise information through the names 95 * listed above so aliasses might be neseccary. 96 * following patters will be replaced: 97 * %{user} user name 98 */ 99$conf['auth']['mysql']['getUserInfo'] = "SELECT pass, CONCAT(firstname,' ',lastname) AS name, email AS mail 100 FROM users 101 WHERE login='%{user}'"; 102 103/* This statement should return a table containing all user login names that meet 104 * certain filter criteria. The filter expressions will be added case dependend by 105 * the module. At the end a sort expression will be added. 106 * Important is that this list contains no double entries fo a user. Each user 107 * name is only allowed once in the table. 108 * The login name will be accessed as 'user' to a alias might be neseccary. 109 * No patterns will be replaced in this statement but following patters will be 110 * replaced in the filter expressions: 111 * %{user} in FilterLogin user's login name 112 * %{name} in FilterName user's full name 113 * %{email} in FilterEmail user's email address 114 * %{group} in FilterGroup group name 115 */ 116$conf['auth']['mysql']['getUsers'] = "SELECT DISTINCT login AS user 117 FROM users AS u 118 LEFT JOIN usergroup AS ug ON u.uid=ug.uid 119 LEFT JOIN groups AS g ON ug.gid=g.gid"; 120$conf['auth']['mysql']['FilterLogin'] = "login LIKE '%{user}'"; 121$conf['auth']['mysql']['FilterName'] = "CONCAT(firstname,' ',lastname) LIKE '%{name}'"; 122$conf['auth']['mysql']['FilterEmail'] = "email LIKE '%{email}'"; 123$conf['auth']['mysql']['FilterGroup'] = "name LIKE '%{group}'"; 124$conf['auth']['mysql']['SortOrder'] = "ORDER BY login"; 125 126/* This statement should add a user to the database. Minimum information to 127 * store are: login name, password, email address and full name. 128 * Following patterns will be replaced: 129 * %{user} user's login name 130 * %{pass} password (encrypted or clear text, depends on 'encryptPass') 131 * %{email} email address 132 * %{name} user's full name 133 */ 134$conf['auth']['mysql']['addUser'] = "INSERT INTO users 135 (login, pass, email, firstname, lastname) 136 VALUES ('%{user}', '%{pass}', '%{email}', 137 SUBSTRING_INDEX('%{name}',' ', 1), 138 SUBSTRING_INDEX('%{name}',' ', -1))"; 139 140/* This statement should remove a user fom the database. 141 * Following patterns will be replaced: 142 * %{user} user's login name 143 * %{uid} id of a user dataset 144 */ 145$conf['auth']['mysql']['delUser'] = "DELETE FROM users 146 WHERE uid='%{uid}'"; 147 148/* This statement should add a group to the database. 149 * Following patterns will be replaced: 150 * %{group} group name 151 */ 152$conf['auth']['mysql']['addGroup'] = "INSERT INTO groups (name) 153 VALUES ('%{group}')"; 154 155/* This statement should remove a group fom the database. 156 * Following patterns will be replaced: 157 * %{group} group name 158 * %{gid} id of a group dataset 159 */ 160$conf['auth']['mysql']['delGroup'] = "DELETE FROM groups 161 WHERE gid='%{gid}'"; 162 163/* This statement should connect a user to a group (a user become member 164 * of that group). 165 * Following patterns will be replaced: 166 * %{user} user's login name 167 * %{uid} id of a user dataset 168 * %{group} group name 169 * %{gid} id of a group dataset 170 */ 171$conf['auth']['mysql']['addUserGroup']= "INSERT INTO usergroup (uid, gid) 172 VALUES ('%{uid}', '%{gid}')"; 173 174/* This statement should remove a single connection from a user to a 175 * group (a user quits membership of that group). 176 * Following patterns will be replaced: 177 * %{user} user's login name 178 * %{uid} id of a user dataset 179 * %{group} group name 180 * %{gid} id of a group dataset 181 */ 182$conf['auth']['mysql']['delUserGroup']= "DELETE FROM usergroup 183 WHERE uid='%{uid}' 184 AND gid='%{gid}'"; 185 186/* This statement should remove all connections from a user to any group 187 * (a user quits membership of all groups). 188 * Following patterns will be replaced: 189 * %{uid} id of a user dataset 190 */ 191$conf['auth']['mysql']['delUserRefs'] = "DELETE FROM usergroup 192 WHERE uid='%{uid}'"; 193 194