summaryrefslogtreecommitdiff
path: root/conf/mysql.conf.php.example
blob: ffe35c466aa41b3b93a1796eb94d05430b427540 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
/*
  This is an example configuration for the mysql auth module.

  This SQL statements are optimized for following table structure.
  If you use a different one you have to change them accordingly.
  See comments of every statement for details.

  TABLE users
      uid   login   pass   firstname   lastname   email
	  
  TABLE groups
      gid   name
	  
  TABLE usergroup
      uid   gid
  
  To use this configuration you have to copy them to local.php
  or at least include this file in local.php.
 */


/* Normally password encryptionis done by DokuWiki (recommended) but for
 * some reasons it might be usefull to let the database do the encryption.
 * Set 'encryptPass' to '1' and the cleartext password is forwarded to
 * the database, otherwise the encrypted one.
 */
$conf['auth']['mysql']['encryptPass'] = 0;

/* Multiple table operations will be protected by locks. This array tolds
 * the module which tables to lock. If you use any aliases for table names
 * these array must also contain these aliases. Any unamed alias will cause
 * a warning suring operation. See the example below.
 */
$conf['auth']['mysql']['TablesToLock']= array("users", "users AS u","groups", "groups AS g", "usergroup", "usergroup AS ug");

/* 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:
 *   %u    user name 
 */
$conf['auth']['mysql']['getUserID']   = "SELECT uid AS id FROM users WHERE login='%u'";

/* 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:
 *   %g    group name 
 */
$conf['auth']['mysql']['getGroupID']  = "SELECT gid AS id FROM groups WHERE name='%g'";

/* 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:
 *   %u    user name
 *   %p    encrypted or clear text password (depends on 'encryptPass')
 *   %g    default group name 
 */
$conf['auth']['mysql']['checkPass']   = "SELECT pass
                                         FROM usergroup AS ug
                                         JOIN users AS u ON u.uid=ug.uid
                                         JOIN groups AS g ON g.gid=ug.gid
                                         WHERE login='%u'
                                         AND name='%g'";

/* 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 nessecary.
 * following patters will be replaced:
 *   %u    user name
 */
$conf['auth']['mysql']['getGroups']   = "SELECT name as `group`
                                         FROM groups g, users u, usergroup ug
                                         WHERE u.uid = ug.uid
                                         AND g.gid = ug.gid
                                         AND u.login='%u'";

/* 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 thise information through the names
 * listed above so aliasses might be neseccary.
 * following patters will be replaced:
 *   %u    user name
 */
$conf['auth']['mysql']['getUserInfo'] = "SELECT pass, CONCAT(firstname,' ',lastname) AS name, email AS mail
                                         FROM users
                                         WHERE login='%u'";

/* This statement should return a table containing all user login names that meet 
 * certain filter criteria. The filter expressions will be added case dependend by
 * the module. At the end a sort expression will be added.
 * Important is that this list contains no double entries fo 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 neseccary.
 * No patterns will be replaced in this statement but following patters will be
 * replaced in the filter expressions:
 *   %u  in FilterLogin  user's login name
 *   %n  in FilterName   user's full name
 *   %e  in FilterEmail  user's email address
 *   %g  in FilterGroup  group name
 */
$conf['auth']['mysql']['getUsers']    = "SELECT DISTINCT login AS user
                                         FROM users AS u 
                                         LEFT JOIN usergroup AS ug ON u.uid=ug.uid
                                         LEFT JOIN groups AS g ON ug.gid=g.gid";
$conf['auth']['mysql']['FilterLogin'] = "login LIKE '%u'";
$conf['auth']['mysql']['FilterName']  = "CONCAT(firstname,' ',lastname) LIKE '%n'";
$conf['auth']['mysql']['FilterEmail'] = "email LIKE '%e'";
$conf['auth']['mysql']['FilterGroup'] = "name LIKE '%g'";
$conf['auth']['mysql']['SortOrder']   = "ORDER BY login";

/* 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:
 *   %u  user's login name
 *   %p  password (encrypted or clear text, depends on 'encryptPass')
 *   %e  email address
 *   %n  user's full name
 */ 
$conf['auth']['mysql']['addUser']     = "INSERT INTO users
                                         (login, pass, email, firstname, lastname)
                                         VALUES ('%u', '%p', '%e',
                                         SUBSTRING_INDEX('%n',' ', 1),
                                         SUBSTRING_INDEX('%n',' ', -1))";

/* This statement should remove a user fom the database.
 * Following patterns will be replaced:
 *   %u    user's login name
 *   %uid  id of a user dataset
 */
$conf['auth']['mysql']['delUser']     = "DELETE FROM users
                                         WHERE uid='%uid'";

/* This statement should add a group to the database.
 * Following patterns will be replaced:
 *   %g    group name
 */
$conf['auth']['mysql']['addGroup']    = "INSERT INTO groups (name)
                                         VALUES ('%g')";

/* This statement should remove a group fom the database.
 * Following patterns will be replaced:
 *   %g    group name
 *   %gid  id of a group dataset
 */
$conf['auth']['mysql']['delGroup']    = "DELETE FROM groups
                                         WHERE gid='%gid'";

/* This statement should connect a user to a group (a user become member
 * of that group).
 * Following patterns will be replaced:
 *   %u    user's login name
 *   %uid  id of a user dataset
 *   %g    group name
 *   %gid  id of a group dataset
 */
$conf['auth']['mysql']['addUserGroup']= "INSERT INTO usergroup (uid, gid)
                                         VALUES ('%uid', '%gid')";

/* 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:
 *   %u    user's login name
 *   %uid  id of a user dataset
 *   %g    group name
 *   %gid  id of a group dataset
 */
$conf['auth']['mysql']['delUserGroup']= "DELETE FROM usergroup
                                         WHERE uid='%uid'
                                         AND gid='%gid'";

/* 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 usergroup
                                         WHERE uid='%uid'";
?>