Permalink
Browse files

Replace getCoreConf() by getContextConf() with context and getGlobalC…

…onf() without. Remove unused resources.
  • Loading branch information...
1 parent 2a4101b commit 7ec6edf3af6daa08cff7138f9d09ab5d715af174 @cdujeu cdujeu committed Jun 21, 2016
Showing with 823 additions and 458 deletions.
  1. +4 −4 core/src/core/src/pydio/Core/Controller/CliRunner.php
  2. +2 −2 core/src/core/src/pydio/Core/Controller/XMLWriter.php
  3. +1 −1 core/src/core/src/pydio/Core/Http/Cli/AuthCliMiddleware.php
  4. +3 −3 core/src/core/src/pydio/Core/Http/Dav/AuthBackendBasic.php
  5. +25 −4 core/src/core/src/pydio/Core/Http/Dav/AuthBackendDigest.php
  6. +14 −1 core/src/core/src/pydio/Core/Http/Dav/BrowserPlugin.php
  7. +12 −5 core/src/core/src/pydio/Core/Http/Dav/DAVServer.php
  8. +4 −4 core/src/core/src/pydio/Core/Http/Response/FileReaderResponse.php
  9. +4 −3 core/src/core/src/pydio/Core/Services/AuthService.php
  10. +24 −10 core/src/core/src/pydio/Core/Services/ConfService.php
  11. +8 −1 core/src/core/src/pydio/Core/Services/LocaleService.php
  12. +12 −4 core/src/core/src/pydio/Core/Services/RepositoryService.php
  13. +10 −10 core/src/core/src/pydio/Core/Services/UsersService.php
  14. +5 −1 core/src/core/src/pydio/Core/Utils/BruteForceHelper.php
  15. +21 −6 core/src/core/src/pydio/Core/Utils/Utils.php
  16. +4 −1 core/src/core/src/pydio/Core/Utils/VarsFilter.php
  17. +9 −1 core/src/core/src/pydio/Tests/PHPCLI.php
  18. +9 −2 core/src/core/src/pydio/Tests/Upload.php
  19. +12 −4 core/src/core/src/pydio/Tests/UsersConfig.php
  20. +93 −13 core/src/plugins/access.fs/class.fsAccessDriver.php
  21. +14 −13 core/src/plugins/action.powerfs/class.PowerFSController.php
  22. +148 −1 core/src/plugins/action.scheduler/class.AjxpScheduler.php
  23. +0 −182 core/src/plugins/action.share/res/public_links.php
  24. +7 −3 core/src/plugins/action.share/src/Legacy/LegacyPubliclet.php
  25. +0 −95 core/src/plugins/action.share/src/Legacy/PublicletCounter.php
  26. +3 −3 core/src/plugins/action.share/src/ShareCenter.php
  27. +7 −4 core/src/plugins/action.share/src/Store/ShareRightsManager.php
  28. +1 −1 core/src/plugins/action.share/src/Store/ShareStore.php
  29. +3 −3 core/src/plugins/action.share/src/View/MinisiteRenderer.php
  30. +13 −6 core/src/plugins/action.share/src/View/PublicAccessManager.php
  31. +0 −1 core/src/plugins/action.share/vendor/composer/autoload_classmap.php
  32. +0 −1 core/src/plugins/action.share/vendor/composer/autoload_static.php
  33. +76 −2 core/src/plugins/auth.remote/class.remoteAuthDriver.php
  34. +25 −3 core/src/plugins/authfront.keystore/class.KeystoreAuthFrontend.php
  35. +2 −2 core/src/plugins/authfront.session_login/class.SessionLoginFrontend.php
  36. +51 −4 core/src/plugins/core.auth/class.AbstractAuthDriver.php
  37. +20 −20 core/src/plugins/core.conf/class.AbstractConfDriver.php
  38. +9 −9 core/src/plugins/core.mailer/class.AjxpMailer.php
  39. +87 −3 core/src/plugins/core.mq/class.MqManager.php
  40. +1 −1 core/src/plugins/core.ocs/src/Server/Dav/AuthSharingBackend.php
  41. +18 −3 core/src/plugins/core.ocs/src/Server/Dav/Server.php
  42. +20 −1 core/src/plugins/core.tasks/src/TaskService.php
  43. +15 −5 core/src/plugins/gui.ajax/class.AJXP_ClientDriver.php
  44. +15 −2 core/src/plugins/gui.user/class.UserGuiController.php
  45. +8 −6 core/src/plugins/uploader.flex/class.FlexUploadProcessor.php
  46. +4 −4 core/src/plugins/uploader.jumploader/class.JumploaderProcessor.php
@@ -75,17 +75,17 @@ public static function applyActionInBackground(ContextInterface $ctx, $actionNam
$logFile = $logDir . "/" . $token . ".out";
if (UsersService::usersEnabled()) {
- $cKey = ConfService::getCoreConf("AJXP_CLI_SECRET_KEY", "conf");
+ $cKey = ConfService::getGlobalConf("AJXP_CLI_SECRET_KEY", "conf");
if (empty($cKey)) {
$cKey = "\1CDAFx¨op#";
}
$user = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($token . $cKey), $user, MCRYPT_MODE_ECB));
}
$robustInstallPath = str_replace("/", DIRECTORY_SEPARATOR, AJXP_INSTALL_PATH);
- $cmd = ConfService::getCoreConf("CLI_PHP") . " " . $robustInstallPath . DIRECTORY_SEPARATOR . "cmd.php -u=$user -t=$token -a=$actionName -r=$repositoryId";
+ $cmd = ConfService::getGlobalConf("CLI_PHP") . " " . $robustInstallPath . DIRECTORY_SEPARATOR . "cmd.php -u=$user -t=$token -a=$actionName -r=$repositoryId";
/* Inserted next 3 lines to quote the command if in windows - rmeske*/
if (PHP_OS == "WIN32" || PHP_OS == "WINNT" || PHP_OS == "Windows") {
- $cmd = ConfService::getCoreConf("CLI_PHP") . " " . chr(34) . $robustInstallPath . DIRECTORY_SEPARATOR . "cmd.php" . chr(34) . " -u=$user -t=$token -a=$actionName -r=$repositoryId";
+ $cmd = ConfService::getGlobalConf("CLI_PHP") . " " . chr(34) . $robustInstallPath . DIRECTORY_SEPARATOR . "cmd.php" . chr(34) . " -u=$user -t=$token -a=$actionName -r=$repositoryId";
}
if (!empty($statusFile)) {
$cmd .= " -s=" . $statusFile;
@@ -132,7 +132,7 @@ public static function runCommandInBackground($cmd, $logFile)
{
if (PHP_OS == "WIN32" || PHP_OS == "WINNT" || PHP_OS == "Windows") {
if (AJXP_SERVER_DEBUG) $cmd .= " > " . $logFile;
- if (class_exists("COM") && ConfService::getCoreConf("CLI_USE_COM")) {
+ if (class_exists("COM") && ConfService::getGlobalConf("CLI_USE_COM")) {
$WshShell = new COM("WScript.Shell");
$WshShell->Run("cmd /C $cmd", 0, false);
} else {
@@ -259,7 +259,7 @@ public static function replaceAjxpXmlKeywords($xml, $stripSpaces = false)
//$xml = str_replace("AJXP_THEME_FOLDER", AJXP_THEME_FOLDER, $xml);
$xml = str_replace("AJXP_SERVER_ACCESS", AJXP_SERVER_ACCESS, $xml);
}
- $xml = str_replace("AJXP_APPLICATION_TITLE", ConfService::getCoreConf("APPLICATION_TITLE"), $xml);
+ $xml = str_replace("AJXP_APPLICATION_TITLE", ConfService::getGlobalConf("APPLICATION_TITLE"), $xml);
$xml = str_replace("AJXP_MIMES_EDITABLE", StatHelper::getAjxpMimes("editable"), $xml);
$xml = str_replace("AJXP_MIMES_IMAGE", StatHelper::getAjxpMimes("image"), $xml);
$xml = str_replace("AJXP_MIMES_AUDIO", StatHelper::getAjxpMimes("audio"), $xml);
@@ -427,7 +427,7 @@ public static function triggerBgAction($actionName, $parameters, $messageId, $pr
public static function triggerBgJSAction($jsCode, $messageId, $print=true, $delay = 0)
{
$data = XMLWriter::write("<trigger_bg_action name=\"javascript_instruction\" messageId=\"$messageId\" delay=\"$delay\">", $print);
- $data .= XMLWriter::write("<clientCallback><![CDATA[".$jsCode."]]></clientCallback>", $print);
+ $data .= XMLWriter::write("<clientCallback><![CDATA[".$jsCode."]]></clientCallback>", $print);
$data .= XMLWriter::write("</trigger_bg_action>", $print);
return $data;
}
@@ -124,7 +124,7 @@ public static function handleRequest(ServerRequestInterface $requestInterface, R
} else {
// Consider "u" is a crypted version of u:p
$optToken = $options["t"];
- $cKey = ConfService::getCoreConf("AJXP_CLI_SECRET_KEY", "conf");
+ $cKey = ConfService::getGlobalConf("AJXP_CLI_SECRET_KEY", "conf");
if(empty($cKey)) $cKey = "\1CDAFx¨op#";
$optUser = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($optToken.$cKey), base64_decode($optUser), MCRYPT_MODE_ECB), "\0");
$env = getenv("AJXP_SAFE_CREDENTIALS");
@@ -123,9 +123,6 @@ public function authenticate(Sabre\DAV\Server $server, $realm)
throw new Sabre\DAV\Exception\NotAuthenticated();
}
$this->updateCurrentUserRights($loggedUser);
- if (ConfService::getCoreConf("SESSION_SET_CREDENTIALS", "auth")) {
- AJXP_Safe::storeCredentials($this->currentUser, $userpass[1]);
- }
if($this->context->hasRepository()){
$repoId = $this->context->getRepositoryId();
try{
@@ -144,6 +141,9 @@ public function authenticate(Sabre\DAV\Server $server, $realm)
// NOW UPDATE CONTEXT
$this->context->setUserId($this->currentUser);
+ if (ConfService::getContextConf($this->context, "SESSION_SET_CREDENTIALS", "auth")) {
+ AJXP_Safe::storeCredentials($this->currentUser, $userpass[1]);
+ }
//PluginsService::getInstance($this->context);
AJXP_Logger::updateContext($this->context);
TextEncoder::updateContext($this->context);
@@ -51,6 +51,10 @@ class AuthBackendDigest extends Sabre\DAV\Auth\Backend\AbstractDigest
*/
private $context;
+ /**
+ * AuthBackendDigest constructor.
+ * @param $context
+ */
public function __construct($context)
{
$this->context = $context;
@@ -61,6 +65,12 @@ public function __construct($context)
}
}
+ /**
+ * @param string $realm
+ * @param string $username
+ * @return bool|string
+ * @throws Sabre\DAV\Exception\NotAuthenticated
+ */
public function getDigestHash($realm, $username)
{
try{
@@ -81,6 +91,12 @@ public function getDigestHash($realm, $username)
}
+ /**
+ * @param Sabre\DAV\Server $server
+ * @param string $realm
+ * @return bool
+ * @throws Sabre\DAV\Exception\NotAuthenticated
+ */
public function authenticate(Sabre\DAV\Server $server, $realm)
{
//AJXP_Logger::debug("Try authentication on $realm", $server);
@@ -104,10 +120,6 @@ public function authenticate(Sabre\DAV\Server $server, $realm)
throw new Sabre\DAV\Exception\NotAuthenticated();
}
$this->updateCurrentUserRights($loggedUser);
- if (ConfService::getCoreConf("SESSION_SET_CREDENTIALS", "auth")) {
- $webdavData = $loggedUser->getPref("AJXP_WEBDAV_DATA");
- AJXP_Safe::storeCredentials($this->currentUser, $this->_decodePassword($webdavData["PASS"], $this->currentUser));
- }
} else {
if ($success === false) {
AJXP_Logger::warning(__CLASS__, "Login failed", array("user" => $this->currentUser, "error" => "Invalid WebDAV user or password"));
@@ -130,6 +142,10 @@ public function authenticate(Sabre\DAV\Server $server, $realm)
}
$this->context->setRepositoryObject($repoObject);
}
+ if (ConfService::getContextConf($this->context, "SESSION_SET_CREDENTIALS", "auth")) {
+ $webdavData = $loggedUser->getPref("AJXP_WEBDAV_DATA");
+ AJXP_Safe::storeCredentials($this->currentUser, $this->_decodePassword($webdavData["PASS"], $this->currentUser));
+ }
// NOW UPDATE CONTEXT
$this->context->setUserObject($loggedUser);
@@ -155,6 +171,11 @@ protected function updateCurrentUserRights($user)
return true;
}
+ /**
+ * @param $encoded
+ * @param $user
+ * @return string
+ */
private function _decodePassword($encoded, $user)
{
if (function_exists('mcrypt_decrypt')) {
@@ -34,18 +34,26 @@ class BrowserPlugin extends Sabre\DAV\Browser\Plugin
protected $repositoryLabel;
+ /**
+ * BrowserPlugin constructor.
+ * @param null $currentRepositoryLabel
+ */
public function __construct($currentRepositoryLabel = null)
{
parent::__construct(false, true);
$this->repositoryLabel = $currentRepositoryLabel;
}
+ /**
+ * @param string $path
+ * @return mixed|string
+ */
public function generateDirectoryIndex($path)
{
$html = parent::generateDirectoryIndex($path);
$html = str_replace("image/vnd.microsoft.icon", "image/png", $html);
- $title = ConfService::getCoreConf("APPLICATION_TITLE");
+ $title = ConfService::getGlobalConf("APPLICATION_TITLE");
$html = preg_replace("/<title>(.*)<\/title>/i", '<title>'.$title.'</title>', $html);
$repoString = "</h1>";
@@ -60,6 +68,11 @@ public function generateDirectoryIndex($path)
}
+ /**
+ * @param string $name
+ * @return string
+ * @throws Sabre\DAV\Exception\Forbidden
+ */
public function getLocalAssetPath($name)
{
if ($name != "favicon.ico") {
@@ -30,7 +30,10 @@
defined('AJXP_EXEC') or die('Access not allowed');
-
+/**
+ * Class DAVServer
+ * @package Pydio\Core\Http\Dav
+ */
class DAVServer
{
/**
@@ -39,13 +42,17 @@ class DAVServer
private static $context;
+ /**
+ * @param $baseURI
+ * @param $davRoute
+ */
public static function handleRoute($baseURI, $davRoute){
ConfService::init();
ConfService::start();
self::$context = Context::emptyContext();
- if (!ConfService::getCoreConf("WEBDAV_ENABLE")) {
+ if (!ConfService::getGlobalConf("WEBDAV_ENABLE")) {
die('You are not allowed to access this service');
}
@@ -92,13 +99,13 @@ public static function handleRoute($baseURI, $davRoute){
}
- if((AuthBackendBasic::detectBasicHeader() || ConfService::getCoreConf("WEBDAV_FORCE_BASIC"))
+ if((AuthBackendBasic::detectBasicHeader() || ConfService::getGlobalConf("WEBDAV_FORCE_BASIC"))
&& ConfService::getAuthDriverImpl()->getOptionAsBool("TRANSMIT_CLEAR_PASS")){
$authBackend = new AuthBackendBasic(self::$context);
} else {
$authBackend = new AuthBackendDigest(self::$context);
}
- $authPlugin = new DAV\Auth\Plugin($authBackend, ConfService::getCoreConf("WEBDAV_DIGESTREALM"));
+ $authPlugin = new DAV\Auth\Plugin($authBackend, ConfService::getGlobalConf("WEBDAV_DIGESTREALM"));
$server->addPlugin($authPlugin);
if (!is_dir(AJXP_DATA_PATH."/plugins/server.sabredav")) {
@@ -112,7 +119,7 @@ public static function handleRoute($baseURI, $davRoute){
$lockPlugin = new DAV\Locks\Plugin($lockBackend);
$server->addPlugin($lockPlugin);
- if (ConfService::getCoreConf("WEBDAV_BROWSER_LISTING")) {
+ if (ConfService::getGlobalConf("WEBDAV_BROWSER_LISTING")) {
$browerPlugin = new BrowserPlugin((isSet($repository)?$repository->getDisplay():null));
$extPlugin = new DAV\Browser\GuessContentType();
$server->addPlugin($browerPlugin);
@@ -176,10 +176,10 @@ public function readFile($node = null, $filePath = null, $data = null, $headerTy
if(!$data === null && !file_exists($filePathOrData)){
throw new \Exception("File $filePathOrData not found!");
}
- $confGzip = ConfService::getCoreConf("GZIP_COMPRESSION");
- $confGzipLimit = ConfService::getCoreConf("GZIP_LIMIT");
- $confUseXSendFile = ConfService::getCoreConf("USE_XSENDFILE");
- $confUseXAccelRedirect = ConfService::getCoreConf("USE_XACCELREDIRECT");
+ $confGzip = ConfService::getGlobalConf("GZIP_COMPRESSION");
+ $confGzipLimit = ConfService::getGlobalConf("GZIP_LIMIT");
+ $confUseXSendFile = ConfService::getGlobalConf("USE_XSENDFILE");
+ $confUseXAccelRedirect = ConfService::getGlobalConf("USE_XACCELREDIRECT");
$fakeReq = ServerRequestFactory::fromGlobals();
$serverParams = $fakeReq->getServerParams();
@@ -113,13 +113,14 @@ public static function logUser($user_id, $pwd, $bypass_pwd = false, $cookieLogin
// Successful login attempt
BruteForceHelper::setBruteForceLoginArray($loginAttempt, true);
+ $user = UsersService::getUserById($user_id, false);
+
// Setting session credentials if asked in config
- if (ConfService::getCoreConf("SESSION_SET_CREDENTIALS", "auth")) {
+ if (ConfService::getContextConf(Context::contextWithObjects($user, null), "SESSION_SET_CREDENTIALS", "auth")) {
list($authId, $authPwd) = $authDriver->filterCredentials($user_id, $pwd);
AJXP_Safe::storeCredentials($authId, $authPwd);
}
- $user = UsersService::getUserById($user_id, false);
if ($user->getLock() === "logout") {
AJXP_Logger::warning(__CLASS__, "Login failed", array("user" => Utils::sanitize($user_id, AJXP_SANITIZE_EMAILCHARS), "error" => "Locked user"));
@@ -171,7 +172,7 @@ public static function disconnect()
AJXP_Logger::info(__CLASS__, "Log Out", "");
unset($_SESSION["AJXP_USER"]);
//if(isSet(self::$currentUser)) unset(self::$currentUser);
- if (ConfService::getCoreConf("SESSION_SET_CREDENTIALS", "auth")) {
+ if (ConfService::getContextConf(Context::contextWithObjects($user, null), "SESSION_SET_CREDENTIALS", "auth")) {
AJXP_Safe::clearCredentials();
}
Controller::applyHook("user.after_disconnect", array(Context::emptyContext(), $userId));
@@ -27,6 +27,7 @@
use Pydio\Core\Model\Context;
+use Pydio\Core\Model\ContextInterface;
use Pydio\Core\PluginFramework\CoreInstanceProvider;
use Pydio\Core\Utils\Utils;
use Pydio\Core\Utils\VarsFilter;
@@ -47,10 +48,7 @@ class ConfService
private $errors = array();
private $configs = array();
-
- private $contextRepositoryId;
- private $contextCharset;
-
+
/**
* @return AbstractConfDriver
@@ -209,7 +207,7 @@ public static function currentContextIsRestAPI($restBase = '')
*/
public static function backgroundActionsSupported()
{
- return function_exists("mcrypt_create_iv") && ConfService::getCoreConf("CMDLINE_ACTIVE");
+ return function_exists("mcrypt_create_iv") && ConfService::getGlobalConf("CMDLINE_ACTIVE");
}
/**
@@ -309,7 +307,7 @@ public static function zipEnabled()
public static function zipBrowsingEnabled()
{
if(!self::zipEnabled()) return false;
- return !ConfService::getCoreConf("DISABLE_ZIP_BROWSING");
+ return !ConfService::getGlobalConf("DISABLE_ZIP_BROWSING");
}
/**
@@ -320,7 +318,7 @@ public static function zipBrowsingEnabled()
public static function zipCreationEnabled()
{
if(!self::zipEnabled()) return false;
- return ConfService::getCoreConf("ZIP_CREATION");
+ return ConfService::getGlobalConf("ZIP_CREATION");
}
/**
@@ -369,23 +367,39 @@ protected function setConfInst($varName, $varValue)
{
$this->configs[$varName] = $varValue;
}
+
/**
- * Get config from the core.$coreType plugin
+ * Get config from the core.$coreType plugin without context
* @static
* @param string $varName
* @param string $coreType
* @return mixed|null|string
*/
- public static function getCoreConf($varName, $coreType = "ajaxplorer")
+ public static function getGlobalConf($varName, $coreType = "ajaxplorer")
{
- $ctx = Context::fromGlobalServices();
+ $ctx = Context::emptyContext();
+ $coreP = PluginsService::getInstance($ctx)->getPluginByTypeName("core", $coreType);
+ if($coreP === false) return null;
+ $confs = $coreP->getConfigs();
+ return (isSet($confs[$varName]) ? VarsFilter::filter($confs[$varName], $ctx) : null);
+ }
+
+ /**
+ * @param ContextInterface $ctx
+ * @param $varName
+ * @param string $coreType
+ * @return mixed
+ */
+ public static function getContextConf(ContextInterface $ctx, $varName, $coreType = "ajaxplorer"){
+
$coreP = PluginsService::getInstance($ctx)->getPluginByTypeName("core", $coreType);
if($coreP === false) return null;
$confs = $coreP->getConfigs();
if($ctx->hasUser()){
$confs = $ctx->getUser()->getMergedRole()->filterPluginConfigs("core".$coreType, $confs, $ctx->getRepositoryId());
}
return (isSet($confs[$varName]) ? VarsFilter::filter($confs[$varName], $ctx) : null);
+
}
/**
Oops, something went wrong.

0 comments on commit 7ec6edf

Please sign in to comment.