-
-
Notifications
You must be signed in to change notification settings - Fork 839
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #541 from splitbrain/multidomainad
Show a domain dropdown when multiple AD domains are configured
- Loading branch information
Showing
6 changed files
with
147 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
/** | ||
* DokuWiki Plugin addomain (Action Component) | ||
* | ||
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html | ||
* @author Andreas Gohr <gohr@cosmocode.de> | ||
*/ | ||
|
||
// must be run within Dokuwiki | ||
if(!defined('DOKU_INC')) die(); | ||
|
||
/** | ||
* Class action_plugin_addomain | ||
*/ | ||
class action_plugin_authad extends DokuWiki_Action_Plugin { | ||
|
||
/** | ||
* Registers a callback function for a given event | ||
*/ | ||
public function register(Doku_Event_Handler &$controller) { | ||
|
||
$controller->register_hook('AUTH_LOGIN_CHECK', 'BEFORE', $this, 'handle_auth_login_check'); | ||
$controller->register_hook('HTML_LOGINFORM_OUTPUT', 'BEFORE', $this, 'handle_html_loginform_output'); | ||
|
||
} | ||
|
||
/** | ||
* Adds the selected domain as user postfix when attempting a login | ||
* | ||
* @param Doku_Event $event | ||
* @param array $param | ||
*/ | ||
public function handle_auth_login_check(Doku_Event &$event, $param) { | ||
global $INPUT; | ||
|
||
/** @var auth_plugin_authad $auth */ | ||
global $auth; | ||
if(!is_a($auth, 'auth_plugin_authad')) return; // AD not even used | ||
|
||
if($INPUT->str('dom')) { | ||
$usr = $auth->cleanUser($event->data['user']); | ||
$dom = $auth->_userDomain($usr); | ||
if(!$dom) { | ||
$usr = "$usr@".$INPUT->str('dom'); | ||
} | ||
$INPUT->post->set('u', $usr); | ||
$event->data['user'] = $usr; | ||
} | ||
} | ||
|
||
/** | ||
* Shows a domain selection in the login form when more than one domain is configured | ||
* | ||
* @param Doku_Event $event | ||
* @param array $param | ||
*/ | ||
public function handle_html_loginform_output(Doku_Event &$event, $param) { | ||
global $INPUT; | ||
/** @var auth_plugin_authad $auth */ | ||
global $auth; | ||
if(!is_a($auth, 'auth_plugin_authad')) return; // AD not even used | ||
$domains = $auth->_getConfiguredDomains(); | ||
if(count($domains) <= 1) return; // no choice at all | ||
|
||
/** @var Doku_Form $form */ | ||
$form =& $event->data; | ||
|
||
// any default? | ||
$dom = ''; | ||
if($INPUT->has('u')) { | ||
$usr = $auth->cleanUser($INPUT->str('u')); | ||
$dom = $auth->_userDomain($usr); | ||
|
||
// update user field value | ||
if($dom) { | ||
$usr = $auth->_userName($usr); | ||
$pos = $form->findElementByAttribute('name', 'u'); | ||
$ele =& $form->getElementAt($pos); | ||
$ele['value'] = $usr; | ||
} | ||
} | ||
|
||
// add select box | ||
$element = form_makeListboxField('dom', $domains, $dom, $this->getLang('domain'), '', 'block'); | ||
$pos = $form->findElementByAttribute('name', 'p'); | ||
$form->insertElement($pos + 1, $element); | ||
} | ||
|
||
} | ||
|
||
// vim:ts=4:sw=4:et: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
/** | ||
* German language file for addomain plugin | ||
* | ||
* @author Andreas Gohr <gohr@cosmocode.de> | ||
*/ | ||
|
||
$lang['domain'] = 'Anmelde-Domäne'; | ||
|
||
//Setup VIM: ex: et ts=4 : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
/** | ||
* English language file for addomain plugin | ||
* | ||
* @author Andreas Gohr <gohr@cosmocode.de> | ||
*/ | ||
|
||
$lang['domain'] = 'Logon Domain'; | ||
|
||
//Setup VIM: ex: et ts=4 : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
/** | ||
* Korean language file for addomain plugin | ||
* | ||
* @author Myeongjin <aranet100@gmail.com> | ||
*/ | ||
|
||
$lang['domain'] = '로그온 도메인'; | ||
|
||
//Setup VIM: ex: et ts=4 : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
base authad | ||
author Andreas Gohr | ||
email andi@splitbrain.org | ||
date 2013-04-25 | ||
date 2014-02-14 | ||
name Active Directory Auth Plugin | ||
desc Provides user authentication against a Microsoft Active Directory | ||
url http://www.dokuwiki.org/plugin:authad |