DokuWiki

It's better when it's simple

User Tools

Site Tools


auth:mysql_e107

This is an old revision of the document!


e107

User authentication with e107.

Tested on

  • e107 0.7.8
  • Dokuwiki 2007-06-26b
  • MySQL 4.1.15 and MySQL 5.0.45
  • php 4.3.11 and php 5.1.6

This assumes that all user accounts will be created and maintained through e107.

Remember: First configure DokuWiki to use MySQL as "authtype" with password encryption "passcrypt" set to “mysql” or “my411” (depending on the version of your MySQL DB). You can do this either by editing local.cfg or via the configuration manager of DokuWiki.

Optionally, change the table prefix in the queries below (I have used the e107 default “e107_”).

$conf['auth']['mysql']['TablesToLock']= 
      array("e107_user", "e107_user AS u", "e107_userclass_classes");
 
$conf['auth']['mysql']['checkPass']   = 
     "SELECT user_password AS pass
      FROM e107_user
      WHERE user_loginname='%{user}'";
 
$conf['auth']['mysql']['getUserInfo'] = 
     "SELECT user_password AS pass, user_name AS name, user_email AS mail
      FROM e107_user
      WHERE user_loginname='%{user}'";
 
$conf['auth']['mysql']['getGroups']   = 
     "SELECT userclass_name as `group`
      FROM e107_user, e107_userclass_classes
      WHERE FIND_IN_SET(e107_userclass_classes.userclass_id, e107_user.user_class) <> 0
      AND e107_user.user_loginname='%{user}'
      UNION
      SELECT 'admin' AS  `group`
      FROM e107_user AS u
      WHERE user_admin <> 0
      AND user_loginname='%{user}'
      UNION
      SELECT 'user' AS `group`";

Notes

  • The getGroups query is slightly particular. It consists of two SELECT statements, joined with a UNION statement. The first select finds all the userclasses the user belongs to in e107. It returns a list with these userclasses as groups to be used in DokuWiki. The second SELECT will add one more group (“admin”) to the list, if the user is defined as an admin in e107. This will enable you to have the same admins in your wiki as in e107. For this to work, you will have to add
    $conf['superuser'] = '@admin';

    in you local.php.

  • The last part of the UNION guarantees that every user with a valid login will land in the default group “@user”. This makes providing an exclusive wiki for all e107 users more easy.
  • The first SELECT statement uses an unusual FIND_IN_SET WHERE clause. This is because e107 doesn't use a separate table to store the user/group relationships. Instead, it uses a single field in the user table that contains a comma separated list of userclasses that user belongs to. As far as I know, FIND_IN_SET is available since MySQL 4.0.x.
  • Probably more of a general remark, but I'll put it here anyway because I came across it in my experiments: when setting up ACL's using this scheme, you may have to encode certain characters in your acl.auth.php file. For example, the groupname
    My-Team

    has to be encoded as

    My%2dTeam

    The ACL admin interface on you DokuWiki site does this automatically for you, so using the webinterface is easiest way to setup your ACL's.

Geert Janssens 2008/10/05 14:53

auth/mysql_e107.1245877204.txt.gz · Last modified: 2009-06-24 23:00 by 84.168.142.67

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki