Skip to content

Instantly share code, notes, and snippets.

@franzliedke
Created June 9, 2013 13:27
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save franzliedke/5743534 to your computer and use it in GitHub Desktop.
Save franzliedke/5743534 to your computer and use it in GitHub Desktop.
FluxBB Authentication Plugin for DokuWiki

Installation

In your DokuWiki installation, create a folder lib/plugins/authfluxbb/ and create the two files auth.php and plugin.info.txt in it.

In your wiki's conf/local.protected.php (create this file if it does not exist), add the following lines:

$conf['authtype'] = 'authfluxbb';
$conf['superuser'] = '@Administrators,@Moderators';

// Make sure stripping slashes doesn't clash with the forums.
if (!defined('FORUM_DISABLE_STRIPSLASHES'))
    define('FORUM_DISABLE_STRIPSLASHES', 1);

// Connect with FluxBB
define('PUN_ROOT', dirname(__FILE__).'/../../');
include_once PUN_ROOT.'include/common.php';

NOTE: Be sure to overwrite the value of PUN_ROOT with the location of your FluxBB installation, relative to the configuration file. (The above example would work if the forum would be located in / and the wiki in /docs/.)

The variable $conf['superusers'] can be used to set the names of the FluxBB groups that have superuser access to the wiki.

<?php
// Must be run within Dokuwiki
if (!defined('DOKU_INC')) die();
/**
* FluxBB auth backend
*
* Check against FluxBB's user cookie.
* Note that PUN_ROOT must be defined correctly.
*
* @author Franz Liedke <franz@fluxbb.org>
* @author Andreas Gohr <andi@splitbrain.org>
*/
class auth_plugin_authfluxbb extends DokuWiki_Auth_Plugin {
/**
* Constructor.
*
* Sets additional capabilities and config strings.
*/
function __construct()
{
parent::__construct();
$this->cando['addUser'] = false;
$this->cando['delUser'] = false;
$this->cando['modLogin'] = false;
$this->cando['modPass'] = false;
$this->cando['modName'] = false;
$this->cando['modMail'] = false;
$this->cando['modGroups'] = false;
$this->cando['getUsers'] = false;
$this->cando['getUserCount'] = false;
$this->cando['getGroups'] = false;
$this->cando['external'] = true;
$this->cando['logout'] = false;
// The auth system was successfully initialized.
$this->success = true;
}
/**
* Do all authentication against the external provider.
*
* @param string $user
* @param string $pass
* @param bool $sticky
* @return bool
*/
function trustExternal($user, $pass, $sticky = false)
{
global $USERINFO;
global $conf;
global $lang;
global $pun_user;
global $pun_config;
global $cookie_name;
if (isset($pun_user) && !$pun_user['is_guest'] && ($pun_user['is_admmod'] || $pun_user['num_posts'] >= 10))
{
// We're logged in - set the globals
$USERINFO['pass'] = $pun_user['password'];
$USERINFO['name'] = utf8_encode($pun_user['realname']);
$USERINFO['mail'] = $pun_user['email'];
$USERINFO['grps'] = array($pun_user['g_title']);
if ($pun_user['is_admmod'])
$USERINFO['grps'][] = 'admin';
$_SERVER['REMOTE_USER'] = $pun_user['username'];
$_SESSION[DOKU_COOKIE]['auth']['user'] = $pun_user['username'];
$_SESSION[DOKU_COOKIE]['auth']['info'] = $USERINFO;
return true;
}
// Make sure we're really logged off.
auth_logoff();
$USERINFO['grps'] = array();
return false;
}
/**
* Return case sensitivity of the backend
*
* @return bool
*/
function isCaseSensitive()
{
return false;
}
}
base authfluxbb
author Franz Liedke
email franz@fluxbb.org
date 2013-06-09
name FluxBB auth plugin
desc Provides authentication using a FluxBB forum
url https://fluxbb.org
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment