xref: /dokuwiki/conf/mysql.conf.php.example (revision 75bfc19c4fec0d9ec349df05c30bbd95e459a5ba)
13ff230f7SMatthias Grimm<?php
23ff230f7SMatthias Grimm/*
33ff230f7SMatthias Grimm  This is an example configuration for the mysql auth module.
43ff230f7SMatthias Grimm
53ff230f7SMatthias Grimm  This SQL statements are optimized for following table structure.
63ff230f7SMatthias Grimm  If you use a different one you have to change them accordingly.
73ff230f7SMatthias Grimm  See comments of every statement for details.
83ff230f7SMatthias Grimm
93ff230f7SMatthias Grimm  TABLE users
103ff230f7SMatthias Grimm      uid   login   pass   firstname   lastname   email
113ff230f7SMatthias Grimm
123ff230f7SMatthias Grimm  TABLE groups
133ff230f7SMatthias Grimm      gid   name
143ff230f7SMatthias Grimm
153ff230f7SMatthias Grimm  TABLE usergroup
163ff230f7SMatthias Grimm      uid   gid
173ff230f7SMatthias Grimm
183ff230f7SMatthias Grimm  To use this configuration you have to copy them to local.php
193ff230f7SMatthias Grimm  or at least include this file in local.php.
203ff230f7SMatthias Grimm */
213ff230f7SMatthias Grimm
223ff230f7SMatthias Grimm
233ff230f7SMatthias Grimm/* Normally password encryptionis done by DokuWiki (recommended) but for
243ff230f7SMatthias Grimm * some reasons it might be usefull to let the database do the encryption.
253ff230f7SMatthias Grimm * Set 'encryptPass' to '1' and the cleartext password is forwarded to
263ff230f7SMatthias Grimm * the database, otherwise the encrypted one.
273ff230f7SMatthias Grimm */
283ff230f7SMatthias Grimm$conf['auth']['mysql']['encryptPass'] = 0;
293ff230f7SMatthias Grimm
303ff230f7SMatthias Grimm/* Multiple table operations will be protected by locks. This array tolds
313ff230f7SMatthias Grimm * the module which tables to lock. If you use any aliases for table names
323ff230f7SMatthias Grimm * these array must also contain these aliases. Any unamed alias will cause
333ff230f7SMatthias Grimm * a warning suring operation. See the example below.
343ff230f7SMatthias Grimm */
353ff230f7SMatthias Grimm$conf['auth']['mysql']['TablesToLock']= array("users", "users AS u","groups", "groups AS g", "usergroup", "usergroup AS ug");
363ff230f7SMatthias Grimm
373ff230f7SMatthias Grimm/* This statement should return the database index of a given user name.
383ff230f7SMatthias Grimm * The module will access the index with the name 'id' so a alias might be
393ff230f7SMatthias Grimm * necessary.
403ff230f7SMatthias Grimm * following patters will be replaced:
413ff230f7SMatthias Grimm *   %u    user name
423ff230f7SMatthias Grimm */
433ff230f7SMatthias Grimm$conf['auth']['mysql']['getUserID']   = "SELECT uid AS id FROM users WHERE login='%u'";
443ff230f7SMatthias Grimm
453ff230f7SMatthias Grimm/* This statement should return the database index of a given group name.
463ff230f7SMatthias Grimm * The module will access the index with the name 'id' so a alias might be
473ff230f7SMatthias Grimm * necessary.
483ff230f7SMatthias Grimm * following patters will be replaced:
493ff230f7SMatthias Grimm *   %g    group name
503ff230f7SMatthias Grimm */
513ff230f7SMatthias Grimm$conf['auth']['mysql']['getGroupID']  = "SELECT gid AS id FROM groups WHERE name='%g'";
523ff230f7SMatthias Grimm
533ff230f7SMatthias Grimm/* This statement is used to grant or deny access to the wiki. The result should
543ff230f7SMatthias Grimm * be a table with exact one line containing at least the password of the user.
553ff230f7SMatthias Grimm * If the result table is empty or contains more than one row, access will be denied.
563ff230f7SMatthias Grimm * The module access the password as 'pass' so a alias might be necessary.
573ff230f7SMatthias Grimm * following patters will be replaced:
583ff230f7SMatthias Grimm *   %u    user name
593ff230f7SMatthias Grimm *   %p    encrypted or clear text password (depends on 'encryptPass')
603ff230f7SMatthias Grimm *   %g    default group name
613ff230f7SMatthias Grimm */
623ff230f7SMatthias Grimm$conf['auth']['mysql']['checkPass']   = "SELECT pass
633ff230f7SMatthias Grimm                                         FROM usergroup AS ug
643ff230f7SMatthias Grimm                                         JOIN users AS u ON u.uid=ug.uid
653ff230f7SMatthias Grimm                                         JOIN groups AS g ON g.gid=ug.gid
663ff230f7SMatthias Grimm                                         WHERE login='%u'
673ff230f7SMatthias Grimm                                         AND name='%g'";
683ff230f7SMatthias Grimm
69*75bfc19cSMatthias Grimm/* This statement is used to get all groups a user is member of. The result should
70*75bfc19cSMatthias Grimm * be a table containing all groups the given user is member of. The module access
71*75bfc19cSMatthias Grimm * the group name as 'group' so a alias might be nessecary.
72*75bfc19cSMatthias Grimm * following patters will be replaced:
73*75bfc19cSMatthias Grimm *   %u    user name
74*75bfc19cSMatthias Grimm */
753ff230f7SMatthias Grimm$conf['auth']['mysql']['getGroups']   = "SELECT name as `group`
763ff230f7SMatthias Grimm                                         FROM groups g, users u, usergroup ug
773ff230f7SMatthias Grimm                                         WHERE u.uid = ug.uid
783ff230f7SMatthias Grimm                                         AND g.gid = ug.gid
793ff230f7SMatthias Grimm                                         AND u.login='%u'";
80*75bfc19cSMatthias Grimm
81*75bfc19cSMatthias Grimm/* This statement should return a table with exact one row containing information
82*75bfc19cSMatthias Grimm * about one user. The field needed are:
83*75bfc19cSMatthias Grimm * 'pass'  containing the encrypted or clear text password
84*75bfc19cSMatthias Grimm * 'name'  the user's full name
85*75bfc19cSMatthias Grimm * 'mail'  the user's email address
86*75bfc19cSMatthias Grimm * Keep in mind that Dokuwiki will access thise information through the names
87*75bfc19cSMatthias Grimm * listed above so aliasses might be neseccary.
88*75bfc19cSMatthias Grimm * following patters will be replaced:
89*75bfc19cSMatthias Grimm *   %u    user name
90*75bfc19cSMatthias Grimm */
913ff230f7SMatthias Grimm$conf['auth']['mysql']['getUserInfo'] = "SELECT pass, CONCAT(firstname,' ',lastname) AS name, email AS mail
923ff230f7SMatthias Grimm                                         FROM users
933ff230f7SMatthias Grimm                                         WHERE login='%u'";
94*75bfc19cSMatthias Grimm
95*75bfc19cSMatthias Grimm/* This statement should return a table containing all user login names that meet
96*75bfc19cSMatthias Grimm * certain filter criteria. The filter expressions will be added case dependend by
97*75bfc19cSMatthias Grimm * the module. At the end a sort expression will be added.
98*75bfc19cSMatthias Grimm * Important is that this list contains no double entries fo a user. Each user
99*75bfc19cSMatthias Grimm * name is only allowed once in the table.
100*75bfc19cSMatthias Grimm * The login name will be accessed as 'user' to a alias might be neseccary.
101*75bfc19cSMatthias Grimm * No patterns will be replaced in this statement but following patters will be
102*75bfc19cSMatthias Grimm * replaced in the filter expressions:
103*75bfc19cSMatthias Grimm *   %u  in FilterLogin  user's login name
104*75bfc19cSMatthias Grimm *   %n  in FilterName   user's full name
105*75bfc19cSMatthias Grimm *   %e  in FilterEmail  user's email address
106*75bfc19cSMatthias Grimm *   %g  in FilterGroup  group name
107*75bfc19cSMatthias Grimm */
1083ff230f7SMatthias Grimm$conf['auth']['mysql']['getUsers']    = "SELECT DISTINCT login AS user
1093ff230f7SMatthias Grimm                                         FROM users AS u
1103ff230f7SMatthias Grimm                                         LEFT JOIN usergroup AS ug ON u.uid=ug.uid
1113ff230f7SMatthias Grimm                                         LEFT JOIN groups AS g ON ug.gid=g.gid";
112*75bfc19cSMatthias Grimm$conf['auth']['mysql']['FilterLogin'] = "login LIKE '%u'";
113*75bfc19cSMatthias Grimm$conf['auth']['mysql']['FilterName']  = "CONCAT(firstname,' ',lastname) LIKE '%n'";
114*75bfc19cSMatthias Grimm$conf['auth']['mysql']['FilterEmail'] = "email LIKE '%e'";
115*75bfc19cSMatthias Grimm$conf['auth']['mysql']['FilterGroup'] = "name LIKE '%g'";
1163ff230f7SMatthias Grimm$conf['auth']['mysql']['SortOrder']   = "ORDER BY login";
1173ff230f7SMatthias Grimm
118*75bfc19cSMatthias Grimm/* This statement should add a user to the database. Minimum information to
119*75bfc19cSMatthias Grimm * store are: login name, password, email address and full name.
120*75bfc19cSMatthias Grimm * Following patterns will be replaced:
121*75bfc19cSMatthias Grimm *   %u  user's login name
122*75bfc19cSMatthias Grimm *   %p  password (encrypted or clear text, depends on 'encryptPass')
123*75bfc19cSMatthias Grimm *   %e  email address
124*75bfc19cSMatthias Grimm *   %n  user's full name
125*75bfc19cSMatthias Grimm */
1263ff230f7SMatthias Grimm$conf['auth']['mysql']['addUser']     = "INSERT INTO users
1273ff230f7SMatthias Grimm                                         (login, pass, email, firstname, lastname)
1283ff230f7SMatthias Grimm                                         VALUES ('%u', '%p', '%e',
1293ff230f7SMatthias Grimm                                         SUBSTRING_INDEX('%n',' ', 1),
1303ff230f7SMatthias Grimm                                         SUBSTRING_INDEX('%n',' ', -1))";
131*75bfc19cSMatthias Grimm
132*75bfc19cSMatthias Grimm/* This statement should remove a user fom the database.
133*75bfc19cSMatthias Grimm * Following patterns will be replaced:
134*75bfc19cSMatthias Grimm *   %u    user's login name
135*75bfc19cSMatthias Grimm *   %uid  id of a user dataset
136*75bfc19cSMatthias Grimm */
1373ff230f7SMatthias Grimm$conf['auth']['mysql']['delUser']     = "DELETE FROM users
1383ff230f7SMatthias Grimm                                         WHERE uid='%uid'";
139*75bfc19cSMatthias Grimm
140*75bfc19cSMatthias Grimm/* This statement should add a group to the database.
141*75bfc19cSMatthias Grimm * Following patterns will be replaced:
142*75bfc19cSMatthias Grimm *   %g    group name
143*75bfc19cSMatthias Grimm */
1443ff230f7SMatthias Grimm$conf['auth']['mysql']['addGroup']    = "INSERT INTO groups (name)
1453ff230f7SMatthias Grimm                                         VALUES ('%g')";
146*75bfc19cSMatthias Grimm
147*75bfc19cSMatthias Grimm/* This statement should remove a group fom the database.
148*75bfc19cSMatthias Grimm * Following patterns will be replaced:
149*75bfc19cSMatthias Grimm *   %g    group name
150*75bfc19cSMatthias Grimm *   %gid  id of a group dataset
151*75bfc19cSMatthias Grimm */
1523ff230f7SMatthias Grimm$conf['auth']['mysql']['delGroup']    = "DELETE FROM groups
1533ff230f7SMatthias Grimm                                         WHERE gid='%gid'";
154*75bfc19cSMatthias Grimm
155*75bfc19cSMatthias Grimm/* This statement should connect a user to a group (a user become member
156*75bfc19cSMatthias Grimm * of that group).
157*75bfc19cSMatthias Grimm * Following patterns will be replaced:
158*75bfc19cSMatthias Grimm *   %u    user's login name
159*75bfc19cSMatthias Grimm *   %uid  id of a user dataset
160*75bfc19cSMatthias Grimm *   %g    group name
161*75bfc19cSMatthias Grimm *   %gid  id of a group dataset
162*75bfc19cSMatthias Grimm */
1633ff230f7SMatthias Grimm$conf['auth']['mysql']['addUserGroup']= "INSERT INTO usergroup (uid, gid)
1643ff230f7SMatthias Grimm                                         VALUES ('%uid', '%gid')";
165*75bfc19cSMatthias Grimm
166*75bfc19cSMatthias Grimm/* This statement should remove a single connection from a user to a
167*75bfc19cSMatthias Grimm * group (a user quits membership of that group).
168*75bfc19cSMatthias Grimm * Following patterns will be replaced:
169*75bfc19cSMatthias Grimm *   %u    user's login name
170*75bfc19cSMatthias Grimm *   %uid  id of a user dataset
171*75bfc19cSMatthias Grimm *   %g    group name
172*75bfc19cSMatthias Grimm *   %gid  id of a group dataset
173*75bfc19cSMatthias Grimm */
1743ff230f7SMatthias Grimm$conf['auth']['mysql']['delUserGroup']= "DELETE FROM usergroup
1753ff230f7SMatthias Grimm                                         WHERE uid='%uid'
1763ff230f7SMatthias Grimm                                         AND gid='%gid'";
177*75bfc19cSMatthias Grimm
178*75bfc19cSMatthias Grimm/* This statement should remove all connections from a user to any group
179*75bfc19cSMatthias Grimm * (a user quits membership of all groups).
180*75bfc19cSMatthias Grimm * Following patterns will be replaced:
181*75bfc19cSMatthias Grimm *   %uid  id of a user dataset
182*75bfc19cSMatthias Grimm */
1833ff230f7SMatthias Grimm$conf['auth']['mysql']['delUserRefs'] = "DELETE FROM usergroup
1843ff230f7SMatthias Grimm                                         WHERE uid='%uid'";
1853ff230f7SMatthias Grimm?>
186