I was Mind Blown by how easy DokuWiki can hook external authentication. I just want to appreciate it, no question here, maybe it will be helpful for someone to google this out.
My website has complex user management and it is already merged with forum software, so using one more authentication was very undesirable, very. DokuWiki really has nice documentation and I solved this big problem within an hour after downloading it first time. I didn't expect that, I thought it will be nightmare, as with others software.
This is basically all I needed:
https://www.dokuwiki.org/devel:authentication_backends. In short:
class auth_plugin_authbkrs extends DokuWiki_Auth_Plugin {
public 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; // TRUE
$this->cando['logout'] = false;
$success = true;
return true;
}
function trustExternal($user, $pass, $sticky=false) {
global $USERINFO;
// HERE WE GO!! MY CODE
if ( !isset($_COOKIE['mycookie']) )
return false;
else
$user = my_function_get_user_from_cookies($_COOKIE['mycookie']); // mysql in my case
// END OF MY CODE
$USERINFO['name'] = $user['username'];
$USERINFO['grps'] = array('user', $user['group']); // based on my website and dokuwiki ACL
$_SERVER['REMOTE_USER'] = $user['username'];
$_SESSION[DOKU_COOKIE]['auth']['user'] = $user['username'];
$_SESSION[DOKU_COOKIE]['auth']['info'] = $USERINFO;
}
}
Then I changed userlink() in common.php and hooked links to users profiles and avatars from my website. Thats all, DokuWiki now is a part of my website. Merge desing was also easy with template.
Big thanks for those, who made DokuWiki so easy to integrate.