Keeyai.com

Grrrrrrrr

The Fleet - A fractal flame by Keeyai

DokuWiki and Wordpress Integration

How to use your wordpress authentication and user system on dokuwiki

This ‘mod’ seamlessly integrates dokuwiki with your current wordpress installation. When you log in on one, you will be logged in on the other, and all the user info is exactly the same. You can visit http://muagames.com for an example. The default roles in wordpress become the user groups in dokuwiki, and you can assign wiki permissions to them as usual (but can’t change/delete them). This requires minimal changes to your dokuwiki install and zero changes to wordpress. You don’t need to know any php or anything else to complete this integration. The entire thing should take about 5 minutes.

Overview:
We are going to be adding a custom authentication module to dokuwiki that will use the wordpress auth tools instead of the default dokuwiki ones. We will also be tweaking some settings so dokuwiki knows what it can and can’t do with user accounts, then setting it up so the wordpress roles become the wiki’s user groups.

Setup and Download
First, upload and install both wordpress and dokuwiki if you haven’t already. I suggest putting them in their own folders in the same directory, but it isn’t necessary. For example, my web folder looks like this:

/web
—-/wordpress
—-/dokuwiki

Whatever your setup is, take note of it because we will need it in the next step. Now, download this zip and extract it somewhere accessible: DokuWiki Wordpress Integration

Step 1: The authentication module
Copy the keeyaiwp.class.php file from the zip into your wiki/inc/auth folder.

Now open it with an editor and find the line that says $wordpresspath = ‘../wordpress/’; It is the first line of code after all the comments. Change this to point to your wordpress folder, relative to your wiki folder. If you used the directory setup above, the default is fine. Make sure the trailing slash is there - the authentication won’t work if it is missing.

Step 2: Wiki configuration options
Navigate to your wiki/conf folder and find local.php. If it doesn’t exist, rename local.php.dist to local.php. This file contains some wiki settings, including telling the wiki to use our new authentication module. Open it up and add/edit the lines below. Note that @administrator is NOT @admin.

        $conf['useacl'] = 1;
	$conf['superuser'] = '@administrator';

	$conf['disableactions'] = 'register';		// Disable the ability to register: handle with wordpress
	$conf['autopasswd'] = 0;					// Disable password autogen: not important if users can't register
	$conf['resendpasswd']= 0;					// Disable password resend:
	$conf['profileconfirm'] = '1';		// password must be verified when editing profile
	$conf['passcrypt'] = 'smd5';			// Not sure what passcrypt needs to be set to, but this works

	// use wordpress login system
	$conf['authtype'] = 'keeyaiwp';

	// default group name
	$conf['defaultgroup']= 'user';

Step 3: Wiki permissions
Navigate to your wiki/conf folder and find acl.auth.php. If it doesn’t exist, rename acl.auth.php.dist to acl.auth.php. This file controls the default permissions for users and groups in your wiki. We are going to be adding the four lower wordpress roles (we already added the administrator role by setting it as the superuser) as wiki user groups. You should tweak these settings so your wiki behaves the way you want it to. The names are the wordpress roles - don’t change them - and the numbers are dokuwiki permissions. Here is the dokuwiki ACL documentation, but if you want to just jump into it, the numbers are 0=none, 1=read, 2=write, create=4, upload=8, and delete=16. Just pick the highest number you need - each one includes all the permissions below it. My defaults allow everyone to read, all logged in users (subscribers, contributors, and authors) to read/edit/create pages, and allows editors and administrators to upload media and delete pages. Only users in the administrators group have access to the wiki’s admin tools.

Open the file and add the following lines (with any adjustments as described above):

	*               @ALL        	1
	*		@editor		16
	*		@author		4
	*		@contributor	4
	*		@subscriber	4

Success!
That’s it! Pretty easy, huh? Now your blog and wiki sign-ins should be perfectly in sync. After doing the above steps one time, you can use the wiki admin tools to further adjust permissions for users and groups, so you should never have to get into the code again.

If you had any problems or have suggestions, please leave a comment. Bug reports, feature requests, link backs, and thank yous are all immensely appreciated.

9 Comments

9 responses so far ↓

  • 1 DokuWiki and Wordpress Integration // Sep 27, 2008 at 7:29 pm

    [...] DokuWiki + Wordpress Integration [...]

  • 2 chris // Nov 8, 2008 at 5:45 pm

    Once again, googling my problems leads me to your blog. Goddammit Collin. Thanks for already having done this for me.

  • 3 Keeyai // Nov 9, 2008 at 7:08 pm

    :D Problem is, I need people I DON’T already know coming here! Glad to help anyway.

  • 4 GalacticCmdr // Jan 20, 2009 at 1:31 am

    Thanks. I found this page with a simple google search and it worked great. I use dokuwiki for my RPG games with WordPress as my front-end. Since I have one wiki per game it was a monumental PITA for logins. This worked the first time out.

  • 5 Keeyai // Jan 20, 2009 at 2:07 am

    It is great to hear when something goes right! I understand how much of a pain multiple logins can be; glad I could help make it easier for you.

  • 6 ganish // Jan 27, 2009 at 5:55 pm

    I also googled and found… I just tried installing and the install went well but it doesn’t seem to be working… I’ve authenticated with WP in another tab so I know my username/pw is correct… In my DW tab, I have tried logging in and I get successfully logged in but my ACL is as @ALL but in WP my account is set as ‘editor’.

    I did discover that DW is picky about the format of acl.auth.php. The fields must be delimited by instead of … Having done that, however, I have set @editor to 16 and @ALL to 1… If I set @ALL to 0, then when I log in as myself, I have no rights to view the page. This is how I’ve determined that my rights fall under @ALL instead of @editor…

    from wp_usermeta:

    | 13 | 2 | wp_capabilities | a:1:{s:6:”editor”;b:1;} |

    Ideas?

  • 7 timmmmyboy // Jan 30, 2009 at 10:52 am

    I’m working on this now but ideally I would like to have the wiki be a subdomain of the wordpress blog eg. wiki.mainblogdomain.com. Any ideas how I would setup the paths correctly in that instance?

  • 8 Keeyai // Feb 1, 2009 at 2:14 am

    @ganish: I’m not sure what is causing your problem — your account DOES work on WP as editor, but only as all on DW? Have you modified your permission setup in WP from the default at all, or installed any plugins that might deal with roles or the like?

    Unfortunately, this was my first foray into WP authentication, so I’m not sure what is causing your problem.

    Also, I haven’t had to change my delimiter as you mentioned above - perhaps changing it is part of the issue.

    See if you can get any more useful information - we will track this down and get you up and running!

  • 9 Keeyai // Feb 1, 2009 at 2:17 am

    @timmmmyboy: Have you tried anything yet and are having trouble, or are you just looking for advice?

    On my hosting, a subdomain is just a sub-folder and I set the server to direct there when a user tries to hit that address (ie, requests to subdomain.mysite.com go to mysite.com/subdomain). The first thing I would try is changing the wordpress path in keeyaiwp.class.php to point to the subdomain - if that doesn’t work, try the subfolder. If neither of those work, post again and we will sort something else out.

You must log in to post a comment.