Skip to content

Instantly share code, notes, and snippets.

@jrenggli
Last active April 15, 2016 14:27
Show Gist options
  • Save jrenggli/6a6ba88d0bfa828bc1ac989ec67ab86c to your computer and use it in GitHub Desktop.
Save jrenggli/6a6ba88d0bfa828bc1ac989ec67ab86c to your computer and use it in GitHub Desktop.
Use TYPO3 users (from be_users table) for authentication in Dokuwiki. This uses the authpdo plugin (https://www.dokuwiki.org/plugin:authpdo)
<?php
/**
*
*
* Currently only read only operations are implemented.
*
* Reminder:
* Configure password in configuration manager before switching authtype to `authpdo`.
* Otherwise you locking yourself out of the system.
*/
$conf['authtype'] = 'authpdo';
$conf['passcrypt'] = 'bcrypt';
...
$conf['plugin']['authpdo']['dsn'] = 'mysql:host=127.0.0.1;dbname=typo3';
$conf['plugin']['authpdo']['user'] = 'typo3';
$conf['plugin']['authpdo']['pass'] = ''; // encrypted password. Best set this in configuration manager
$conf['plugin']['authpdo']['select-user'] = 'SELECT uid,
username AS user,
realName AS name,
password AS hash,
email AS mail
FROM be_users
WHERE username = :user
AND disable = 0
AND deleted = 0
AND (starttime < UNIX_TIMESTAMP())
AND (endtime=0 OR endtime > UNIX_TIMESTAMP())';
$conf['plugin']['authpdo']['select-user-groups'] = 'SELECT G.title AS `group`
FROM be_groups AS G
WHERE FIND_IN_SET(
G.uid,
(
SELECT U.usergroup_cached_list
FROM be_users AS U
WHERE U.uid = :uid
)
)
AND G.deleted = 0
AND G.hidden = 0
UNION
SELECT \'admin\' AS `group`
FROM be_users
WHERE uid = :uid AND admin=1';
$conf['plugin']['authpdo']['select-groups'] = 'SELECT uid AS gid, title AS group
FROM be_groups
AND deleted = 0
AND hidden = 0';
$conf['plugin']['authpdo']['list-users'] = 'SELECT DISTINCT username AS user
FROM be_users
WHERE username LIKE :user
AND realName LIKE :name
AND email LIKE :mail
AND disable = 0
AND deleted = 0
AND (starttime < UNIX_TIMESTAMP())
AND (endtime=0 OR endtime > UNIX_TIMESTAMP())
ORDER BY user
LIMIT :start,:limit';
$conf['plugin']['authpdo']['count-users'] = 'SELECT COUNT(DISTINCT username) AS count
FROM be_users
WHERE disable = 0
AND deleted = 0
AND (starttime < UNIX_TIMESTAMP())
AND (endtime=0 OR endtime > UNIX_TIMESTAMP())';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment