1# authsqlite
2Authentication mechanism for DokuWiki that uses an SQLite database for
3its data store.
4
5This is heavily plagiarismed from authpgsql, because the two database
6engines support a similar SQL syntax.
7
8Configuration is similar to PostgreSQL.  In addition to the configuration
9options for PostgreSQL, authsqlite allows the %{animal} parameter in all
10sql statements.  %{animal} is the animal component of a wiki farm setup,
11and corresponds to the folder where the animal's configuration and data
12files live.
13
14This is the configuration for a farm, where a single authentication
15database contains all of the user information, but group membership is
16different for each animal.
17
18	$conf['plugin']['authsqlite']['checkPass'] =
19		'SELECT pass FROM usergroup AS ug
20		JOIN user AS u ON u.uid=ug.uid
21		JOIN groups AS g ON g.gid=ug.gid
22		WHERE u.login=\'%{user}\'
23			AND g.name=\'%{dgroup}\'';
24	$conf['plugin']['authsqlite']['getUserInfo'] =
25		'SELECT pass, fullname AS name, email AS mail
26		FROM user WHERE login=\'%{user}\'';
27	$conf['plugin']['authsqlite']['getGroups'] =
28		'SELECT g.name AS \'group\' FROM groups g, user u,
29		usergroup ug WHERE u.uid = ug.uid
30			AND ug.animal=\'%{animal}\'
31			AND g.gid = ug.gid AND u.login=\'%{user}\'';
32	$conf['plugin']['authsqlite']['getUsers'] =
33		'SELECT DISTINCT u.login AS user FROM user AS u
34		LEFT JOIN usergroup AS ug ON u.uid=ug.uid AND ug.animal=\'%{animal}\'
35		LEFT JOIN groups AS g ON ug.gid=g.gid';
36	$conf['plugin']['authsqlite']['FilterLogin'] = 'u.login LIKE \'%{user}\'';
37	$conf['plugin']['authsqlite']['FilterName'] = 'u.fullname LIKE \'%{name}\'';
38	$conf['plugin']['authsqlite']['FilterEmail'] = 'u.email LIKE \'%{email}\'';
39	$conf['plugin']['authsqlite']['FilterGroup'] = 'g.name LIKE \'%{group}\'';
40	$conf['plugin']['authsqlite']['SortOrder'] = 'ORDER BY u.login';
41	$conf['plugin']['authsqlite']['addUser'] =
42		'INSERT INTO user (login, pass, email, fullname)
43		VALUES (\'%{user}\', \'%{pass}\', \'%{email}\', \'%{name}\')';
44	$conf['plugin']['authsqlite']['addGroup'] =
45		'INSERT INTO groups (name) VALUES (\'%{group}\')';
46	$conf['plugin']['authsqlite']['addUserGroup'] =
47		'INSERT INTO usergroup (uid, gid, animal) VALUES (%{uid}, %{gid}, \'%{animal}\')';
48	$conf['plugin']['authsqlite']['delGroup'] = 'DELETE FROM groups WHERE gid=%{gid}';
49	$conf['plugin']['authsqlite']['getUserID'] =
50		'SELECT uid AS id FROM user WHERE login=\'%{user}\'';
51	$conf['plugin']['authsqlite']['delUser'] = 'DELETE FROM user WHERE uid=%{uid}';
52	$conf['plugin']['authsqlite']['delUserRefs'] = 'DELETE FROM usergroup WHERE uid=%{uid}';
53	$conf['plugin']['authsqlite']['updateUser'] = 'UPDATE user SET';
54	$conf['plugin']['authsqlite']['UpdateLogin'] = 'login=\'%{user}\'';
55	$conf['plugin']['authsqlite']['UpdatePass'] = 'pass=\'%{pass}\'';
56	$conf['plugin']['authsqlite']['UpdateEmail'] = 'email=\'%{email}\'';
57	$conf['plugin']['authsqlite']['UpdateName'] = 'fullname=\'%{name}\'';
58	$conf['plugin']['authsqlite']['UpdateTarget'] = 'WHERE uid=%{uid}';
59	$conf['plugin']['authsqlite']['delUserGroup'] =
60		'DELETE from usergroup WHERE uid=%{uid} AND gid=%{gid} AND animal=\'%{animal}\'';
61