Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Move Multi & WebFTP login screen into dedicated authfront plugin, as …
Browse files Browse the repository at this point in the history
…previous fixes in AJXP_PluginsService changes the plugins loading order.
  • Loading branch information
cdujeu committed Mar 5, 2015
1 parent e63e0a8 commit 7f24062
Show file tree
Hide file tree
Showing 9 changed files with 348 additions and 277 deletions.
8 changes: 6 additions & 2 deletions core/src/core/classes/class.AuthService.php
Expand Up @@ -730,8 +730,9 @@ public static function checkPassword($userId, $userPass, $cookieString = false,
$res = $userObject->checkCookieString($userPass);
return $res;
}
$seed = $authDriver->getSeed(false);
if($seed != $returnSeed) return false;
if($authDriver->getOption("TRANSMIT_CLEAR_PASS") !== true){
if($authDriver->getSeed(false) != $returnSeed) return false;
}
return $authDriver->checkPassword($userId, $userPass, $returnSeed);
}
/**
Expand Down Expand Up @@ -972,6 +973,8 @@ public static function countUsersForRepository($repositoryId, $details = false)
* @param $limit
* @param bool $cleanLosts
* @param bool $recursive
* @param null $countCallback
* @param null $loopCallback
* @return AbstractAjxpUser[]
*/
public static function listUsers($baseGroup = "/", $regexp = null, $offset = -1, $limit = -1, $cleanLosts = true, $recursive = true, $countCallback = null, $loopCallback = null)
Expand Down Expand Up @@ -1064,6 +1067,7 @@ public static function authSupportsPagination()
* @param string $regexp
* @param null $filterProperty Can be "parent" or "admin"
* @param null $filterValue Can be a string, or constants AJXP_FILTER_EMPTY / AJXP_FILTER_NOT_EMPTY
* @param bool $recursive
* @return int
*/
public static function authCountUsers($baseGroup="/", $regexp="", $filterProperty = null, $filterValue = null, $recursive = true)
Expand Down
26 changes: 7 additions & 19 deletions core/src/plugins/auth.ftp/class.ftpAuthDriver.php
Expand Up @@ -39,28 +39,16 @@ class ftpAuthDriver extends AbstractAuthDriver
{
public $driverName = "ftp";

protected function parseSpecificContributions(&$contribNode)
{
parent::parseSpecificContributions($contribNode);
if($contribNode->nodeName != "actions") return ;
$actionXpath=new DOMXPath($contribNode->ownerDocument);
if (!isset($this->options["FTP_LOGIN_SCREEN"]) || $this->options["FTP_LOGIN_SCREEN"] != "TRUE" || $this->options["FTP_LOGIN_SCREEN"] === false) {
// Remove "login" && "ftp_set_data" actions
$nodeList = $actionXpath->query('action[@name="login"]', $contribNode);
if(!$nodeList->length) return ;
foreach($nodeList as $nodeChild){
$contribNode->removeChild($nodeChild);
}
$nodeList = $actionXpath->query('action[@name="ftp_set_data"]', $contribNode);
if(!$nodeList->length) return ;
unset($this->actions["ftp_set_data"]);
$contribNode->removeChild($node = $nodeList->item(0));
} else {
// Local "login" will replace standard one.
public function init($options){
parent::init($options);
if (!isset($this->options["FTP_LOGIN_SCREEN"]) || $this->options["FTP_LOGIN_SCREEN"] != "TRUE" || $this->options["FTP_LOGIN_SCREEN"] === false){
return;
}
// ENABLE WEBFTP LOGIN SCREEN
$this->logDebug(__FUNCTION__, "Enabling authfront.webftp");
AJXP_PluginsService::findPluginById("authfront.webftp")->enabled = true;
}


public function listUsers()
{
$adminUser = $this->options["AJXP_ADMIN_LOGIN"];
Expand Down
77 changes: 0 additions & 77 deletions core/src/plugins/auth.ftp/manifest.xml
Expand Up @@ -25,83 +25,6 @@
<serverCallback methodName="setFtpDataCallback"/>
</processing>
</action>
<action name="login">
<processing>
<clientCallback prepareModal="true"><![CDATA[
var loginRedirect = AJXP_LOGIN_REDIRECT;
if(loginRedirect){
document.location.href=loginRedirect;
}else{
modal.showDialogForm('Log In', 'ftp_login_form',
function(oForm){
ajaxplorer.loadSeedOrCaptcha(oForm.down('#login_seed'), oForm.down('img#captcha_image'), oForm.down('div.dialogLegend'), 'before');
},
function(){
var oForm = modal.getForm();
var connexion = new Connexion();
connexion.addParameter("get_action", "set_ftp_data");
oForm.getElements().each(function(el){
if(el.name != "userid" && el.name!="password" && el.name != "get_action" && el.name!="login_seed"){
connexion.addParameter(el.name, el.getValue());
}
});
connexion.onComplete = function(transport){
ajaxplorer.actionBar.submitForm(oForm, true, function(transport){
ajaxplorer.actionBar.parseXmlMessage(transport.responseXML);
if(transport.responseXML && XPathGetSingleNodeText(transport.responseXML.documentElement, "logging_result/@value") == "-4"){
ajaxplorer.loadSeedOrCaptcha(oForm.down('#login_seed'), oForm.down('img#captcha_image'), oForm.down('div.dialogLegend'), 'before');
}
});
oForm.reset();
};
connexion.sendSync();
return false;
});
}
]]></clientCallback>
</processing>
</action>
<action name="login">
<processing>
<clientForm id="ftp_login_form"><![CDATA[
<div id="ftp_login_form" action="login" box_width="350">
<input type="hidden" name="get_action" value="login">
<input type="hidden" name="login_seed" id="login_seed" value="-1">
<div>
<table cellpadding="2" border="0" cellspacing="0" style="font-size:11px;margin-bottom:5px;">
<tr>
<td colspan="4">
<div class="dialogLegend" ajxp_message_id="ftp_auth.1">AJXP_MESSAGE[ftp_auth.1]</div>
</td>
</tr>
<tr>
<td align="right"><ajxp:message ajxp_message_id="ftp_auth.2">AJXP_MESSAGE[ftp_auth.2]</ajxp:message> </td><td colspan="3"><input type="text" name="FTP_HOST" style="width: 190px; padding:0px; margin-right: 10px;" class="dialogFocus"><ajxp:message ajxp_message_id="ftp_auth.8">AJXP_MESSAGE[ftp_auth.8]</ajxp:message> &nbsp;<input type="text" name="FTP_PORT" style="width: 25px; padding:0px;" value="21"></td>
</tr>
<tr>
<td align="right"><ajxp:message ajxp_message_id="181">AJXP_MESSAGE[181]</ajxp:message> </td><td><input type="text" name="userid" style="width: 100px; padding:0px;"></td>
<td align="right"><ajxp:message ajxp_message_id="182">AJXP_MESSAGE[182]</ajxp:message> </td><td><input type="password" name="password" style="width: 90px; padding:0px;"></td>
</tr>
<tr>
<td colspan="4">
<div class="dialogLegend" style="margin-top: 12px;" ajxp_message_id="ftp_auth.3">AJXP_MESSAGE[ftp_auth.3]</div>
</td>
</tr>
<tr>
<td align="right"><ajxp:message ajxp_message_id="ftp_auth.4">AJXP_MESSAGE[ftp_auth.4]</ajxp:message> </td><td><input type="text" name="PATH" style="width: 100px; padding:0px;" class="" value="/"></td>
<td align="right" style="padding-left:10px;"><ajxp:message ajxp_message_id="ftp_auth.5">AJXP_MESSAGE[ftp_auth.5]</ajxp:message> </td><td><input type="radio" name="FTP_SECURE" style="width: 12px; padding:0px;" value="FALSE" checked><label style="display:inline-block;width:27px;"> FTP</label><input type="radio" name="FTP_SECURE" style="width: 12px; padding:0px;" value="TRUE"><label style="display:inline-block;width:27px;"> FTPS</label></td>
</tr>
<tr>
<td align="right"><ajxp:message ajxp_message_id="ftp_auth.6">AJXP_MESSAGE[ftp_auth.6]</ajxp:message> </td><td><input type="text" name="CHARSET" style="width: 100px; padding:0px;" class="" value=""></td>
<td align="right"><ajxp:message ajxp_message_id="ftp_auth.7">AJXP_MESSAGE[ftp_auth.7]</ajxp:message> </td><td><input type="radio" name="FTP_DIRECT" style="width: 12px; padding:0px;" value="TRUE"><label style="display:inline-block;width:27px;">AJXP_MESSAGE[440]</label><input type="radio" name="FTP_DIRECT" style="width: 12px; padding:0px;" value="FALSE" checked><label style="display:inline-block;width:27px;">AJXP_MESSAGE[441]</label></td>
</tr>
</table>
</div>
</div>
]]></clientForm>
</processing>
</action>
<!-- OVERRIDE LOGOUT -->
<action name="ftp_logout" expireDefault="true">
<gui text="164" title="169" src="decrypted.png"
Expand Down
61 changes: 6 additions & 55 deletions core/src/plugins/auth.multi/class.multiAuthDriver.php
Expand Up @@ -66,6 +66,12 @@ public function init($options)
}
$this->drivers[$name] = $instance;
}
if(!$this->masterSlaveMode){
// Enable Multiple choice login screen
$multi = AJXP_PluginsService::getInstance()->findPluginById("authfront.multi");
$multi->enabled = true;
$multi->options = $this->options;
}
// THE "LOAD REGISTRY CONTRIBUTIONS" METHOD
// WILL BE CALLED LATER, TO BE SURE THAT THE
// SESSION IS ALREADY STARTED.
Expand Down Expand Up @@ -95,61 +101,6 @@ private function detectCurrentDriver()
$this->setCurrentDriverName($authSource);
}

protected function parseSpecificContributions(&$contribNode)
{
parent::parseSpecificContributions($contribNode);
if($contribNode->nodeName != "actions") return ;

if($this->masterSlaveMode) {
// REMOVE CHILD
$actionXpath=new DOMXPath($contribNode->ownerDocument);
$actionOverrideNodeList = $actionXpath->query('//action', $contribNode);
$actionNode = $actionOverrideNodeList->item(0);
if($actionNode->parentNode) $actionNode->parentNode->removeChild($actionNode);

}else{

$actionXpath=new DOMXPath($contribNode->ownerDocument);
$loginCallbackNodeList = $actionXpath->query('//clientCallback', $contribNode);
$callbackNode = $loginCallbackNodeList->item(0);
$xmlContent = $callbackNode->firstChild->wholeText;

$sources = array();
if(!isSet($this->options) || !isSet($this->options["DRIVERS"]) || !is_array($this->options["DRIVERS"])) return;
foreach ($this->getOption("DRIVERS") as $driverDef) {
$dName = $driverDef["NAME"];
if (isSet($driverDef["LABEL"])) {
$dLabel = $driverDef["LABEL"];
} else {
$dLabel = $driverDef["NAME"];
}
$sources[$dName] = $dLabel;
}
$xmlContent = str_replace("AJXP_MULTIAUTH_SOURCES", json_encode($sources), $xmlContent);
$xmlContent = str_replace("AJXP_MULTIAUTH_MASTER", $this->getOption("MASTER_DRIVER"), $xmlContent);
$xmlContent = str_replace("AJXP_USER_ID_SEPARATOR", $this->getOption("USER_ID_SEPARATOR"), $xmlContent);
if($callbackNode) {
$callbackNode->removeChild($callbackNode->firstChild);
$callbackNode->appendChild($contribNode->ownerDocument->createCDATASection($xmlContent));
}

}
}
/*
public function getLoginRedirect(){
$l = $this->drivers[$this->masterName]->getLoginRedirect();
if(!empty($l)) return $l;
return $this->drivers[$this->slaveName]->getLoginRedirect();
}
public function getLogoutRedirect(){
$l = $this->drivers[$this->masterName]->getLogoutRedirect();
if(!empty($l)) return $l;
return $this->drivers[$this->slaveName]->getLogoutRedirect();
}
*/
protected function setCurrentDriverName($name)
{
$this->currentDriver = $name;
Expand Down

0 comments on commit 7f24062

Please sign in to comment.