mysql.conf.php.example 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <?php
  2. /*
  3. * This is an example configuration for the mysql auth plugin.
  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.protected.php
  19. * or at least include this file in local.protected.php.
  20. */
  21. /* Options to configure database access. You need to set up this
  22. * options carefully, otherwise you won't be able to access you
  23. * database.
  24. */
  25. $conf['plugin']['authmysql']['server'] = '';
  26. $conf['plugin']['authmysql']['user'] = '';
  27. $conf['plugin']['authmysql']['password'] = '';
  28. $conf['plugin']['authmysql']['database'] = '';
  29. /* This option enables debug messages in the mysql plugin. It is
  30. * mostly useful for system admins.
  31. */
  32. $conf['plugin']['authmysql']['debug'] = 0;
  33. /* Normally password encryption is done by DokuWiki (recommended) but for
  34. * some reasons it might be useful to let the database do the encryption.
  35. * Set 'forwardClearPass' to '1' and the cleartext password is forwarded to
  36. * the database, otherwise the encrypted one.
  37. */
  38. $conf['plugin']['authmysql']['forwardClearPass'] = 0;
  39. /* Multiple table operations will be protected by locks. This array tells
  40. * the plugin which tables to lock. If you use any aliases for table names
  41. * these array must also contain these aliases. Any unnamed alias will cause
  42. * a warning during operation. See the example below.
  43. */
  44. $conf['plugin']['authmysql']['TablesToLock']= array("users", "users AS u","groups", "groups AS g", "usergroup", "usergroup AS ug");
  45. /***********************************************************************/
  46. /* Basic SQL statements for user authentication (required) */
  47. /***********************************************************************/
  48. /* This statement is used to grant or deny access to the wiki. The result
  49. * should be a table with exact one line containing at least the password
  50. * of the user. If the result table is empty or contains more than one
  51. * row, access will be denied.
  52. *
  53. * The plugin accesses the password as 'pass' so an alias might be necessary.
  54. *
  55. * Following patters will be replaced:
  56. * %{user} user name
  57. * %{pass} encrypted or clear text password (depends on 'encryptPass')
  58. * %{dgroup} default group name
  59. */
  60. $conf['plugin']['authmysql']['checkPass'] = "SELECT pass
  61. FROM usergroup AS ug
  62. JOIN users AS u ON u.uid=ug.uid
  63. JOIN groups AS g ON g.gid=ug.gid
  64. WHERE login='%{user}'
  65. AND name='%{dgroup}'";
  66. /* This statement should return a table with exact one row containing
  67. * information about one user. The field needed are:
  68. * 'pass' containing the encrypted or clear text password
  69. * 'name' the user's full name
  70. * 'mail' the user's email address
  71. *
  72. * Keep in mind that Dokuwiki will access this information through the
  73. * names listed above so aliases might be necessary.
  74. *
  75. * Following patters will be replaced:
  76. * %{user} user name
  77. */
  78. $conf['plugin']['authmysql']['getUserInfo'] = "SELECT pass, CONCAT(firstname,' ',lastname) AS name, email AS mail
  79. FROM users
  80. WHERE login='%{user}'";
  81. /* This statement is used to get all groups a user is member of. The
  82. * result should be a table containing all groups the given user is
  83. * member of. The plugin accesses the group name as 'group' so an alias
  84. * might be necessary.
  85. *
  86. * Following patters will be replaced:
  87. * %{user} user name
  88. */
  89. $conf['plugin']['authmysql']['getGroups'] = "SELECT name as `group`
  90. FROM groups g, users u, usergroup ug
  91. WHERE u.uid = ug.uid
  92. AND g.gid = ug.gid
  93. AND u.login='%{user}'";
  94. /***********************************************************************/
  95. /* Additional minimum SQL statements to use the user manager */
  96. /***********************************************************************/
  97. /* This statement should return a table containing all user login names
  98. * that meet certain filter criteria. The filter expressions will be added
  99. * case dependent by the plugin. At the end a sort expression will be added.
  100. * Important is that this list contains no double entries for a user. Each
  101. * user name is only allowed once in the table.
  102. *
  103. * The login name will be accessed as 'user' to an alias might be necessary.
  104. * No patterns will be replaced in this statement but following patters
  105. * will be replaced in the filter expressions:
  106. * %{user} in FilterLogin user's login name
  107. * %{name} in FilterName user's full name
  108. * %{email} in FilterEmail user's email address
  109. * %{group} in FilterGroup group name
  110. */
  111. $conf['plugin']['authmysql']['getUsers'] = "SELECT DISTINCT login AS user
  112. FROM users AS u
  113. LEFT JOIN usergroup AS ug ON u.uid=ug.uid
  114. LEFT JOIN groups AS g ON ug.gid=g.gid";
  115. $conf['plugin']['authmysql']['FilterLogin'] = "login LIKE '%{user}'";
  116. $conf['plugin']['authmysql']['FilterName'] = "CONCAT(firstname,' ',lastname) LIKE '%{name}'";
  117. $conf['plugin']['authmysql']['FilterEmail'] = "email LIKE '%{email}'";
  118. $conf['plugin']['authmysql']['FilterGroup'] = "name LIKE '%{group}'";
  119. $conf['plugin']['authmysql']['SortOrder'] = "ORDER BY login";
  120. /***********************************************************************/
  121. /* Additional SQL statements to add new users with the user manager */
  122. /***********************************************************************/
  123. /* This statement should add a user to the database. Minimum information
  124. * to store are: login name, password, email address and full name.
  125. *
  126. * Following patterns will be replaced:
  127. * %{user} user's login name
  128. * %{pass} password (encrypted or clear text, depends on 'encryptPass')
  129. * %{email} email address
  130. * %{name} user's full name
  131. */
  132. $conf['plugin']['authmysql']['addUser'] = "INSERT INTO users
  133. (login, pass, email, firstname, lastname)
  134. VALUES ('%{user}', '%{pass}', '%{email}',
  135. SUBSTRING_INDEX('%{name}',' ', 1),
  136. SUBSTRING_INDEX('%{name}',' ', -1))";
  137. /* This statement should add a group to the database.
  138. * Following patterns will be replaced:
  139. * %{group} group name
  140. */
  141. $conf['plugin']['authmysql']['addGroup'] = "INSERT INTO groups (name)
  142. VALUES ('%{group}')";
  143. /* This statement should connect a user to a group (a user become member
  144. * of that group).
  145. * Following patterns will be replaced:
  146. * %{user} user's login name
  147. * %{uid} id of a user dataset
  148. * %{group} group name
  149. * %{gid} id of a group dataset
  150. */
  151. $conf['plugin']['authmysql']['addUserGroup']= "INSERT INTO usergroup (uid, gid)
  152. VALUES ('%{uid}', '%{gid}')";
  153. /* This statement should remove a group fom the database.
  154. * Following patterns will be replaced:
  155. * %{group} group name
  156. * %{gid} id of a group dataset
  157. */
  158. $conf['plugin']['authmysql']['delGroup'] = "DELETE FROM groups
  159. WHERE gid='%{gid}'";
  160. /* This statement should return the database index of a given user name.
  161. * The plugin will access the index with the name 'id' so an alias might be
  162. * necessary.
  163. * following patters will be replaced:
  164. * %{user} user name
  165. */
  166. $conf['plugin']['authmysql']['getUserID'] = "SELECT uid AS id
  167. FROM users
  168. WHERE login='%{user}'";
  169. /***********************************************************************/
  170. /* Additional SQL statements to delete users with the user manager */
  171. /***********************************************************************/
  172. /* This statement should remove a user fom the database.
  173. * Following patterns will be replaced:
  174. * %{user} user's login name
  175. * %{uid} id of a user dataset
  176. */
  177. $conf['plugin']['authmysql']['delUser'] = "DELETE FROM users
  178. WHERE uid='%{uid}'";
  179. /* This statement should remove all connections from a user to any group
  180. * (a user quits membership of all groups).
  181. * Following patterns will be replaced:
  182. * %{uid} id of a user dataset
  183. */
  184. $conf['plugin']['authmysql']['delUserRefs'] = "DELETE FROM usergroup
  185. WHERE uid='%{uid}'";
  186. /***********************************************************************/
  187. /* Additional SQL statements to modify users with the user manager */
  188. /***********************************************************************/
  189. /* This statements should modify a user entry in the database. The
  190. * statements UpdateLogin, UpdatePass, UpdateEmail and UpdateName will be
  191. * added to updateUser on demand. Only changed parameters will be used.
  192. *
  193. * Following patterns will be replaced:
  194. * %{user} user's login name
  195. * %{pass} password (encrypted or clear text, depends on 'encryptPass')
  196. * %{email} email address
  197. * %{name} user's full name
  198. * %{uid} user id that should be updated
  199. */
  200. $conf['plugin']['authmysql']['updateUser'] = "UPDATE users SET";
  201. $conf['plugin']['authmysql']['UpdateLogin'] = "login='%{user}'";
  202. $conf['plugin']['authmysql']['UpdatePass'] = "pass='%{pass}'";
  203. $conf['plugin']['authmysql']['UpdateEmail'] = "email='%{email}'";
  204. $conf['plugin']['authmysql']['UpdateName'] = "firstname=SUBSTRING_INDEX('%{name}',' ', 1),
  205. lastname=SUBSTRING_INDEX('%{name}',' ', -1)";
  206. $conf['plugin']['authmysql']['UpdateTarget']= "WHERE uid=%{uid}";
  207. /* This statement should remove a single connection from a user to a
  208. * group (a user quits membership of that group).
  209. *
  210. * Following patterns will be replaced:
  211. * %{user} user's login name
  212. * %{uid} id of a user dataset
  213. * %{group} group name
  214. * %{gid} id of a group dataset
  215. */
  216. $conf['plugin']['authmysql']['delUserGroup']= "DELETE FROM usergroup
  217. WHERE uid='%{uid}'
  218. AND gid='%{gid}'";
  219. /* This statement should return the database index of a given group name.
  220. * The plugin will access the index with the name 'id' so an alias might
  221. * be necessary.
  222. *
  223. * Following patters will be replaced:
  224. * %{group} group name
  225. */
  226. $conf['plugin']['authmysql']['getGroupID'] = "SELECT gid AS id
  227. FROM groups
  228. WHERE name='%{group}'";