xref: /dokuwiki/conf/mysql.conf.php.example (revision 3ff230f7a83037178c07da3e76b11633d3e76e3f)
1*3ff230f7SMatthias Grimm<?php
2*3ff230f7SMatthias Grimm/*
3*3ff230f7SMatthias Grimm  This is an example configuration for the mysql auth module.
4*3ff230f7SMatthias Grimm
5*3ff230f7SMatthias Grimm  This SQL statements are optimized for following table structure.
6*3ff230f7SMatthias Grimm  If you use a different one you have to change them accordingly.
7*3ff230f7SMatthias Grimm  See comments of every statement for details.
8*3ff230f7SMatthias Grimm
9*3ff230f7SMatthias Grimm  TABLE users
10*3ff230f7SMatthias Grimm      uid   login   pass   firstname   lastname   email
11*3ff230f7SMatthias Grimm
12*3ff230f7SMatthias Grimm  TABLE groups
13*3ff230f7SMatthias Grimm      gid   name
14*3ff230f7SMatthias Grimm
15*3ff230f7SMatthias Grimm  TABLE usergroup
16*3ff230f7SMatthias Grimm      uid   gid
17*3ff230f7SMatthias Grimm
18*3ff230f7SMatthias Grimm  To use this configuration you have to copy them to local.php
19*3ff230f7SMatthias Grimm  or at least include this file in local.php.
20*3ff230f7SMatthias Grimm */
21*3ff230f7SMatthias Grimm
22*3ff230f7SMatthias Grimm
23*3ff230f7SMatthias Grimm/* Normally password encryptionis done by DokuWiki (recommended) but for
24*3ff230f7SMatthias Grimm * some reasons it might be usefull to let the database do the encryption.
25*3ff230f7SMatthias Grimm * Set 'encryptPass' to '1' and the cleartext password is forwarded to
26*3ff230f7SMatthias Grimm * the database, otherwise the encrypted one.
27*3ff230f7SMatthias Grimm */
28*3ff230f7SMatthias Grimm$conf['auth']['mysql']['encryptPass'] = 0;
29*3ff230f7SMatthias Grimm
30*3ff230f7SMatthias Grimm/* Multiple table operations will be protected by locks. This array tolds
31*3ff230f7SMatthias Grimm * the module which tables to lock. If you use any aliases for table names
32*3ff230f7SMatthias Grimm * these array must also contain these aliases. Any unamed alias will cause
33*3ff230f7SMatthias Grimm * a warning suring operation. See the example below.
34*3ff230f7SMatthias Grimm */
35*3ff230f7SMatthias Grimm$conf['auth']['mysql']['TablesToLock']= array("users", "users AS u","groups", "groups AS g", "usergroup", "usergroup AS ug");
36*3ff230f7SMatthias Grimm
37*3ff230f7SMatthias Grimm/* This statement should return the database index of a given user name.
38*3ff230f7SMatthias Grimm * The module will access the index with the name 'id' so a alias might be
39*3ff230f7SMatthias Grimm * necessary.
40*3ff230f7SMatthias Grimm * following patters will be replaced:
41*3ff230f7SMatthias Grimm *   %u    user name
42*3ff230f7SMatthias Grimm */
43*3ff230f7SMatthias Grimm$conf['auth']['mysql']['getUserID']   = "SELECT uid AS id FROM users WHERE login='%u'";
44*3ff230f7SMatthias Grimm
45*3ff230f7SMatthias Grimm/* This statement should return the database index of a given group name.
46*3ff230f7SMatthias Grimm * The module will access the index with the name 'id' so a alias might be
47*3ff230f7SMatthias Grimm * necessary.
48*3ff230f7SMatthias Grimm * following patters will be replaced:
49*3ff230f7SMatthias Grimm *   %g    group name
50*3ff230f7SMatthias Grimm */
51*3ff230f7SMatthias Grimm$conf['auth']['mysql']['getGroupID']  = "SELECT gid AS id FROM groups WHERE name='%g'";
52*3ff230f7SMatthias Grimm
53*3ff230f7SMatthias Grimm/* This statement is used to grant or deny access to the wiki. The result should
54*3ff230f7SMatthias Grimm * be a table with exact one line containing at least the password of the user.
55*3ff230f7SMatthias Grimm * If the result table is empty or contains more than one row, access will be denied.
56*3ff230f7SMatthias Grimm * The module access the password as 'pass' so a alias might be necessary.
57*3ff230f7SMatthias Grimm * following patters will be replaced:
58*3ff230f7SMatthias Grimm *   %u    user name
59*3ff230f7SMatthias Grimm *   %p    encrypted or clear text password (depends on 'encryptPass')
60*3ff230f7SMatthias Grimm *   %g    default group name
61*3ff230f7SMatthias Grimm */
62*3ff230f7SMatthias Grimm$conf['auth']['mysql']['checkPass']   = "SELECT pass
63*3ff230f7SMatthias Grimm                                         FROM usergroup AS ug
64*3ff230f7SMatthias Grimm                                         JOIN users AS u ON u.uid=ug.uid
65*3ff230f7SMatthias Grimm                                         JOIN groups AS g ON g.gid=ug.gid
66*3ff230f7SMatthias Grimm                                         WHERE login='%u'
67*3ff230f7SMatthias Grimm                                         AND name='%g'";
68*3ff230f7SMatthias Grimm
69*3ff230f7SMatthias Grimm$conf['auth']['mysql']['getGroups']   = "SELECT name as `group`
70*3ff230f7SMatthias Grimm                                         FROM groups g, users u, usergroup ug
71*3ff230f7SMatthias Grimm                                         WHERE u.uid = ug.uid
72*3ff230f7SMatthias Grimm                                         AND g.gid = ug.gid
73*3ff230f7SMatthias Grimm                                         AND u.login='%u'";
74*3ff230f7SMatthias Grimm$conf['auth']['mysql']['getUserInfo'] = "SELECT pass, CONCAT(firstname,' ',lastname) AS name, email AS mail
75*3ff230f7SMatthias Grimm                                         FROM users
76*3ff230f7SMatthias Grimm                                         WHERE login='%u'";
77*3ff230f7SMatthias Grimm$conf['auth']['mysql']['getUsers']    = "SELECT DISTINCT login AS user
78*3ff230f7SMatthias Grimm                                         FROM users AS u
79*3ff230f7SMatthias Grimm                                         LEFT JOIN usergroup AS ug ON u.uid=ug.uid
80*3ff230f7SMatthias Grimm                                         LEFT JOIN groups AS g ON ug.gid=g.gid";
81*3ff230f7SMatthias Grimm
82*3ff230f7SMatthias Grimm$conf['auth']['mysql']['SortOrder']   = "ORDER BY login";
83*3ff230f7SMatthias Grimm$conf['auth']['mysql']['FilterLogin'] = "login LIKE '%s'";
84*3ff230f7SMatthias Grimm$conf['auth']['mysql']['FilterName']  = "CONCAT(firstname,' ',lastname) LIKE '%s'";
85*3ff230f7SMatthias Grimm$conf['auth']['mysql']['FilterEmail'] = "email LIKE '%s'";
86*3ff230f7SMatthias Grimm$conf['auth']['mysql']['FilterGroup'] = "name LIKE '%s'";
87*3ff230f7SMatthias Grimm
88*3ff230f7SMatthias Grimm$conf['auth']['mysql']['addUser']     = "INSERT INTO users
89*3ff230f7SMatthias Grimm                                         (login, pass, email, firstname, lastname)
90*3ff230f7SMatthias Grimm                                         VALUES ('%u', '%p', '%e',
91*3ff230f7SMatthias Grimm                                         SUBSTRING_INDEX('%n',' ', 1),
92*3ff230f7SMatthias Grimm                                         SUBSTRING_INDEX('%n',' ', -1))";
93*3ff230f7SMatthias Grimm$conf['auth']['mysql']['delUser']     = "DELETE FROM users
94*3ff230f7SMatthias Grimm                                         WHERE uid='%uid'";
95*3ff230f7SMatthias Grimm$conf['auth']['mysql']['addGroup']    = "INSERT INTO groups (name)
96*3ff230f7SMatthias Grimm                                         VALUES ('%g')";
97*3ff230f7SMatthias Grimm$conf['auth']['mysql']['delGroup']    = "DELETE FROM groups
98*3ff230f7SMatthias Grimm                                         WHERE gid='%gid'";
99*3ff230f7SMatthias Grimm$conf['auth']['mysql']['addUserGroup']= "INSERT INTO usergroup (uid, gid)
100*3ff230f7SMatthias Grimm                                         VALUES ('%uid', '%gid')";
101*3ff230f7SMatthias Grimm$conf['auth']['mysql']['delUserGroup']= "DELETE FROM usergroup
102*3ff230f7SMatthias Grimm                                         WHERE uid='%uid'
103*3ff230f7SMatthias Grimm                                         AND gid='%gid'";
104*3ff230f7SMatthias Grimm$conf['auth']['mysql']['delUserRefs'] = "DELETE FROM usergroup
105*3ff230f7SMatthias Grimm                                         WHERE uid='%uid'";
106*3ff230f7SMatthias Grimm?>
107