Table of Contents

Authentication Plugins

Info on this page is for 2013-05-10 “Weatherwax” and later

Below are the docs for new auth plugins. It may contain errors! Please report them, all feedback is welcome.

(For reference the old documentation can be found at the old development docs and the old authentication modules itself)

DokuWiki's authentication system is highly modular and can, generally speaking, authenticate using anything that is accessible from PHP. Available Auth Plugins are listed.

In summary, there are two distinct ways of building your authentication plugin. Firstly, you can create a plugin that implements all DokuWiki's methods needed to gather user info and verify users. Secondly, you can use the trustExternal() method, which will replace the Dokuwiki authentication functions. You handle the authentication in this method by calling your own backend.

Synopsis

An Authentication Plugin Example needs:

Moreover, a plugin.info.txt file is needed. For full details of plugins and their files and how to create more auth components refer to plugin file structure.

Required implementation

You need to implement at least two fields and three methods.

Fields:

Methods:

Only a few functions need to be implemented. But the more you do the more the frontend will be able to do. See lib/plugins/auth.php for the methods' arguments and return values and for an example implementation see lib/plugins/authplain/auth.php the plain authentication backend, DokuWikis default.

Optional implementation

All these methods are optional and will only be called if the appropriate $cando fields are set

Inherited methods

Notes

Config loading sequence

At the moment, temporary, also the config of old style auth modules are loaded.
The loading order is:

  1. Default config settings
  2. Old style auth module config settings (i.e. $conf['auth']['yourauthbackend']))
  3. The current auth plugin settings (i.e. $conf['plugin']['yourauthplugin']).

Start session customization

(Available since release 2014-05-05 “Ponder Stibbons”)

Dokuwiki starts (in inc/init.php) a session prior to using the authentication plugin. If your framework uses specific session settings, you can define before your own settings in the file conf/local.protected.php. You need to create it when non-existing. In this conf/local.protected.php you can supply one or more of these defines:

The defines correspond to the arguments of session_set_cookie_params(), please refer to its docs for more details. To use SSL for your cookies, you enable the securecookie configuration setting.

Example
conf/local.protected.php
//settings specific for use of the ... authentication plugin
define ('DOKU_SESSION_NAME', "YOURSESSIONNAME");
define ('DOKU_SESSION_LIFETIME', 0);
//etc...
 
//a custom session path
$sessiepath = fullpath(dirname(__FILE__) . '/../../') . '/session';
session_save_path($sessiepath);

About autoloading

Your backend (or its framework) cannot use __autoload to include further classes, those classes must be loaded manually via require()

Handling of old auth backends

When you update your wiki to the 2013-05-10 “Weatherwax” release, you need an auth plugin for the authentication, because the authentication backends aren't supported anymore. The previous bundled authentication backends are already converted to auth plugins: AuthPlain, AuthMySQL, AuthPgSQL, AuthAD and AuthLDAP.

When you use another plugin than the bundled one, you need to check if someone has already shared the auth plugin version in the plugin repository. You can filter the plugins by Auth plugintype. Or you should rewrite the authentication backend yourself. See Howto update your old backend below.

Update wiki to new backend

When you used the plain authentication backend before, DokuWiki will pick up the new authplain due to DokuWiki's defaults are updated too. For all other values of the authtype configuration, you get the warning User authentication is temporarily unavailable. If this situation persists, please inform your Wiki Admin. and you cannot login anymore. This can be solved by updating the authtype configuration to the auth plugin version of your desired backend. When you use a not bundled auth plugin you should first install this one.

When your desired auth plugin is installed you can modify your the authtype configuration setting in conf/local.php (or conf/local.protected.php) by an editor on your server by prefixing your <authentication backend name> with auth to auth<authentication backend name>:

conf/local.php
...
// $conf['authtype'] = 'example';  //auth backend
$conf['authtype'] = 'authexample'; //auth plugin
...

Howto install an auth plugin via plugin manager without working backend?

When you prefer to install an auth plugin by the DokuWiki plugin manager, you need to switch to the plain authentication backend. You need access to the configuration file conf/local.php on you server. Open it in an editor and remove the line from conf/local.php or conf/local.protected.php:

// $conf['authtype'] = '...'; //disable your authtype config

or change that line to:

$conf['authtype'] = 'authplain';

and save the file. Now your wiki uses the AuthPlain plugin. Next you login as superuser. Hint: Probably you can login by the user you define on installation (the installer creates default that users as superuser). Now you can use the plugin manager as usually.

Next you can configure the plugin settings via the configuration manager (these settings are stored in conf/local.php) or you can save these protected against changes from the configuration manager by creating and editing the file conf/local.protected.php. Lastly, you change the authtype configuration to your new auth plugin and save. When your wiki becomes inaccessible again, you can modify the configuration settings via an editor on your server again.

See farther for more info about the configuration files and the config manager.

Old configurations

When auth plugin is activated, and there is an old config available, then first the old auth backend is loaded, next the new auth plugin config is loaded. So when auth plugin configuration settings are set these overwrite the old auth backend values.

Complete load sequence of plugin config settings:

  1. settings from lib/plugins/<pluginname>/conf/default.php
  2. settings from conf/local.php (or possibly overwritten by conf/local.protected.php) where:
    1. first settings of $config['auth']['<authbackendname>'] are read
    2. and next settings of $config['plugin']['auth<authbackendname>']

Tip:
When you start changing settings of auth plugin, especially when you reset a setting to its plugin default, it is recommended to remove the old $config['auth']['<authbackendname>'] settings from the local.php and/or local.protected.php.

Howto update your old backend

Some tips on updating your backend from inc/auth/<authname>.class.php to an Auth plugin.

Simple approach:

  1. Create a plugin skelet corresponding to plugin file structure and the synopsis at top of this page. (skelet generator: http://pluginwiz.dokuwiki.org/)
    • Please prefix the plugin name of your Auth plugin by auth e.g. authexample.
  2. You can reuse the code from inc/auth/<authbackendname>.class.php in your new lib/plugins/auth<authbackendname>/auth.php.
    • Be aware you can load other plugins or helper plugins
    • There are some inherited functions for localisation, configuration and more, see inherited methods above.

FIXME more relevant directions??

Further reading

1)
defined in lib/plugins/auth.php