Permalink
Browse files

Context propagation

  • Loading branch information...
1 parent dcfadd3 commit 1e0dc69162714ca39fc9c683ecff03e562968937 @cdujeu cdujeu committed Jun 7, 2016
Showing with 1,030 additions and 1,417 deletions.
  1. +10 −16 core/src/core/src/pydio/Core/Controller/Controller.php
  2. +10 −7 core/src/core/src/pydio/Core/Controller/XMLWriter.php
  3. +17 −1 core/src/core/src/pydio/Core/Model/RepositoryInterface.php
  4. +1 −11 core/src/core/src/pydio/Core/Model/UserInterface.php
  5. +2 −2 core/src/core/src/pydio/Core/PluginFramework/PluginsService.php
  6. +2 −52 core/src/core/src/pydio/Core/Services/AuthService.php
  7. +3 −2 core/src/core/src/pydio/Core/Services/ConfService.php
  8. +4 −3 core/src/core/src/pydio/Core/Utils/Utils.php
  9. +22 −38 core/src/core/src/pydio/Core/Utils/VarsFilter.php
  10. +2 −1 core/src/core/src/pydio/Tests/Writeability.php
  11. +12 −9 core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php
  12. +4 −7 core/src/plugins/access.dropbox/class.dropboxAccessDriver.php
  13. +6 −3 core/src/plugins/access.dropbox/class.dropboxWrapper.php
  14. +271 −407 core/src/plugins/access.fs/class.fsAccessDriver.php
  15. +11 −12 core/src/plugins/access.fs/class.fsAccessWrapper.php
  16. +0 −2 core/src/plugins/access.fs/manifest.xml
  17. +11 −9 core/src/plugins/access.fs/test.fsAccess.php
  18. +5 −4 core/src/plugins/access.ftp/class.ftpAccessDriver.php
  19. +38 −29 core/src/plugins/access.ftp/class.ftpAccessWrapper.php
  20. +4 −10 core/src/plugins/access.imap/class.imapAccessDriver.php
  21. +11 −8 core/src/plugins/access.imap/class.imapAccessWrapper.php
  22. +24 −26 core/src/plugins/access.mysql/class.mysqlAccessDriver.php
  23. +5 −61 core/src/plugins/access.s3/class.s3AccessDriver.php
  24. +33 −33 core/src/plugins/access.s3/class.s3AccessWrapper.php
  25. +6 −5 core/src/plugins/access.sftp/class.sftpAccessDriver.php
  26. +33 −34 core/src/plugins/access.sftp/class.sftpAccessWrapper.php
  27. +1 −4 core/src/plugins/access.sftp_psl/class.sftpPSLAccessDriver.php
  28. +20 −20 core/src/plugins/access.sftp_psl/class.sftpPSLAccessWrapper.php
  29. +1 −1 core/src/plugins/access.smb/class.smbAccessDriver.php
  30. +17 −7 core/src/plugins/access.smb/class.smbAccessWrapper.php
  31. +10 −10 core/src/plugins/access.swift/class.swiftAccessDriver.php
  32. +12 −11 core/src/plugins/access.swift/class.swiftAccessWrapper.php
  33. +4 −3 core/src/plugins/access.webdav/src/Driver.php
  34. +8 −5 core/src/plugins/access.wms/class.WmsBrowser.php
  35. +5 −3 core/src/plugins/action.powerfs/class.PowerFSController.php
  36. +3 −4 core/src/plugins/action.scheduler/class.AjxpScheduler.php
  37. +0 −1 core/src/plugins/action.share/manifest.xml
  38. +0 −208 core/src/plugins/action.share/src/Legacy/LegacyPubliclet.php
  39. +8 −11 core/src/plugins/action.share/src/ShareCenter.php
  40. +3 −31 core/src/plugins/action.share/src/Store/ShareStore.php
  41. +3 −8 core/src/plugins/action.share/src/View/PublicAccessManager.php
  42. +8 −2 core/src/plugins/action.updater/class.AjaXplorerUpgrader.php
  43. +1 −1 core/src/plugins/action.updater/class.UpdateController.php
  44. +2 −1 core/src/plugins/auth.custom_db/class.customDbAuthDriver.php
  45. +1 −1 core/src/plugins/auth.serial/class.serialAuthDriver.php
  46. +4 −5 core/src/plugins/auth.smb/class.smbAuthDriver.php
  47. +3 −2 core/src/plugins/boot.conf/class.BootConfLoader.php
  48. +5 −4 core/src/plugins/conf.serial/class.AJXP_SerialUser.php
  49. +30 −17 core/src/plugins/conf.serial/class.serialConfDriver.php
  50. +10 −9 core/src/plugins/core.access/src/AbstractAccessDriver.php
  51. +32 −4 core/src/plugins/core.access/src/Model/AJXP_Node.php
  52. +69 −10 core/src/plugins/core.access/src/Model/Repository.php
  53. +18 −13 core/src/plugins/core.access/src/Model/UserSelection.php
  54. +2 −1 core/src/plugins/core.access/src/Stream/AuthWrapper.php
  55. +8 −10 core/src/plugins/core.access/src/Stream/OAuthWrapper.php
  56. +4 −3 core/src/plugins/core.access/src/Stream/PathWrapper.php
  57. +5 −2 core/src/plugins/core.ajaxplorer/manifest.xml
  58. +22 −19 core/src/plugins/core.auth/class.AJXP_Safe.php
  59. +1 −15 core/src/plugins/core.conf/class.AbstractAjxpUser.php
  60. +4 −4 core/src/plugins/core.conf/class.AbstractConfDriver.php
  61. +1 −1 core/src/plugins/core.index/class.AbstractSearchEngineIndexer.php
  62. +1 −1 core/src/plugins/core.meta/class.AJXP_AbstractMetaSource.php
  63. +2 −2 core/src/plugins/core.mq/class.MqManager.php
  64. +3 −0 core/src/plugins/core.notifications/class.AJXP_Notification.php
  65. +4 −1 core/src/plugins/core.notifications/class.AJXP_NotificationCenter.php
  66. +5 −4 core/src/plugins/cypher.encfs/class.EncfsMounter.php
  67. +2 −2 core/src/plugins/editor.audio/class.AudioPreviewer.php
  68. +14 −17 core/src/plugins/editor.eml/class.EmlParser.php
  69. +1 −1 core/src/plugins/index.elasticsearch/class.AjxpElasticSearch.php
  70. +1 −1 core/src/plugins/log.text/class.textLogDriver.php
  71. +2 −2 core/src/plugins/meta.git/class.GitManager.php
  72. +2 −2 core/src/plugins/meta.monitor_fs/class.FSMonitoringManager.php
  73. +23 −21 core/src/plugins/meta.mount/class.FilesystemMounter.php
  74. +63 −85 core/src/plugins/meta.quota/class.QuotaComputer.php
  75. +19 −18 core/src/plugins/meta.svn/class.SvnManager.php
  76. +6 −6 core/src/plugins/meta.syncable/class.ChangesTracker.php
  77. +2 −2 core/src/plugins/metastore.s3/class.s3MetaStore.php
  78. +5 −6 core/src/plugins/metastore.serial/class.SerialMetaStore.php
  79. +1 −1 core/src/plugins/metastore.xattr/class.xAttrMetaStore.php
  80. +1 −1 core/src/plugins/uploader.jumploader/class.JumploaderProcessor.php
  81. +1 −1 core/src/plugins/uploader.plupload/class.PluploadProcessor.php
@@ -257,7 +257,7 @@ public static function applyTaskInBackground(Task $task){
$parameters = $task->getParameters();
$task->setStatus(Task::STATUS_RUNNING);
TaskService::getInstance()->updateTask($task);
- self::applyActionInBackground($task->getWsId(), $task->getAction(), $parameters, $task->getUserId(), "", $task->getId());
+ self::applyActionInBackground($task->getContext(), $task->getAction(), $parameters, "", $task->getId());
}
@@ -279,29 +279,23 @@ public static function executableRequest(ContextInterface $context, $action, $pa
/**
* Launch a command-line version of the framework by passing the actionName & parameters as arguments.
* @static
- * @param String $currentRepositoryId
+ * @param ContextInterface $ctx
* @param String $actionName
* @param array $parameters
- * @param string $user
* @param string $statusFile
* @param string $taskId
* @return null|UnixProcess
*/
- public static function applyActionInBackground($currentRepositoryId, $actionName, $parameters, $user ="", $statusFile = "", $taskId = null)
+ public static function applyActionInBackground(ContextInterface $ctx, $actionName, $parameters, $statusFile = "", $taskId = null)
{
+ $repositoryId = $ctx->getRepositoryId();
+ $user = $ctx->hasUser() ? $ctx->getUser()->getId() : "shared";
$token = md5(time());
$logDir = AJXP_CACHE_DIR."/cmd_outputs";
if(!is_dir($logDir)) mkdir($logDir, 0755);
$logFile = $logDir."/".$token.".out";
- if (empty($user)) {
- if(AuthService::usersEnabled() && AuthService::getLoggedUser() !== null) {
- $user = AuthService::getLoggedUser()->getId();
- }else {
- $user = "shared";
- }
- }
-
+
if (Services\AuthService::usersEnabled()) {
$cKey = ConfService::getCoreConf("AJXP_CLI_SECRET_KEY", "conf");
if(empty($cKey)){
@@ -310,10 +304,10 @@ public static function applyActionInBackground($currentRepositoryId, $actionName
$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=$currentRepositoryId";
+ $cmd = ConfService::getCoreConf("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=$currentRepositoryId";
+ $cmd = ConfService::getCoreConf("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;
@@ -334,9 +328,9 @@ public static function applyActionInBackground($currentRepositoryId, $actionName
}
}
- $repoObject = ConfService::getRepositoryById($currentRepositoryId);
+ $repoObject = $ctx->getRepository();
$clearEnv = false;
- if($repoObject->getOption("USE_SESSION_CREDENTIALS")){
+ if($repoObject->getContextOption($ctx, "USE_SESSION_CREDENTIALS")){
$encodedCreds = AJXP_Safe::getEncodedCredentialString();
if(!empty($encodedCreds)){
putenv("AJXP_SAFE_CREDENTIALS=".$encodedCreds);
@@ -22,6 +22,7 @@
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\IAjxpWrapperProvider;
+use Pydio\Core\Model\Context;
use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Model\RepositoryInterface;
use Pydio\Core\Utils\Utils;
@@ -512,13 +513,13 @@ public static function getUserXML(ContextInterface $ctx, $userObject = null)
if (!Services\AuthService::usersEnabled()) {
$buffer.="<user id=\"shared\">";
$buffer.="<active_repo id=\"".$currentRepoId."\" write=\"1\" read=\"1\"/>";
- $buffer.= XMLWriter::writeRepositoriesData(null);
+ $buffer.= XMLWriter::writeRepositoriesData($ctx);
$buffer.="</user>";
} else if ($loggedUser != null) {
$lock = $loggedUser->getLock();
$buffer.="<user id=\"".$loggedUser->id."\">";
$buffer.="<active_repo id=\"".$currentRepoId."\" write=\"".($loggedUser->canWrite($currentRepoId)?"1":"0")."\" read=\"".($loggedUser->canRead($currentRepoId)?"1":"0")."\"/>";
- $buffer.= XMLWriter::writeRepositoriesData($loggedUser);
+ $buffer.= XMLWriter::writeRepositoriesData($ctx);
$buffer.="<preferences>";
$preferences = $confDriver->getExposedPreferences($loggedUser);
foreach ($preferences as $prefName => $prefData) {
@@ -555,11 +556,12 @@ public static function getUserXML(ContextInterface $ctx, $userObject = null)
/**
* Write the repositories access rights in XML format
* @static
- * @param AbstractAjxpUser|null $loggedUser * @internal param bool $details
+ * @param ContextInterface $ctx
* @return string
*/
- public static function writeRepositoriesData($loggedUser)
+ public static function writeRepositoriesData(ContextInterface $ctx)
{
+ $loggedUser = $ctx->getUser();
$st = "<repositories>";
$streams = ConfService::detectRepositoryStreams(false);
@@ -653,7 +655,7 @@ public static function repositoryToXML($repoId, $repoObject, $exposed, $streams,
$ownerLabel = null;
if ($repoObject->hasOwner()) {
$uId = $repoObject->getOwner();
- if(Services\AuthService::usersEnabled() && Services\AuthService::getLoggedUser()->getId() == $uId){
+ if($loggedUser != null && $loggedUser->getId() == $uId){
$currentUserIsOwner = true;
}
$label = ConfService::getUserPersonalParameter("USER_DISPLAY_NAME", $uId, "core.conf", $uId);
@@ -671,12 +673,13 @@ public static function repositoryToXML($repoId, $repoObject, $exposed, $streams,
if (!empty($description)) {
$descTag = '<description>'.Utils::xmlEntities($description, true).'</description>';
}
+ $ctx = Context::contextWithObjects($loggedUser, $repoObject);
$roleString="";
if($loggedUser != null){
$merged = $loggedUser->mergedRole;
$params = array();
foreach($exposed as $exposed_prop){
- $metaOptions = $repoObject->getOption("META_SOURCES");
+ $metaOptions = $repoObject->getContextOption($ctx, "META_SOURCES");
if(!isSet($metaOptions[$exposed_prop["PLUGIN_ID"]])){
continue;
}
@@ -696,7 +699,7 @@ public static function repositoryToXML($repoId, $repoObject, $exposed, $streams,
$roleString.= ' hasMask="true" ';
}
}
- return "<repo access_type=\"".$repoObject->accessType."\" id=\"".$repoId."\"$statusString $streamString $slugString $isSharedString $roleString><label>".TextEncoder::toUTF8(Utils::xmlEntities($repoObject->getDisplay()))."</label>".$descTag.$repoObject->getClientSettings()."</repo>";
+ return "<repo access_type=\"".$repoObject->accessType."\" id=\"".$repoId."\"$statusString $streamString $slugString $isSharedString $roleString><label>".TextEncoder::toUTF8(Utils::xmlEntities($repoObject->getDisplay()))."</label>".$descTag.$repoObject->getClientSettings($ctx)."</repo>";
}
@@ -111,9 +111,10 @@ public function setSlug($slug = null);
/**
* Get the <client_settings> content of the manifest.xml
+ * @param ContextInterface $ctx
* @return \DOMElement|\DOMNodeList|string
*/
- public function getClientSettings();
+ public function getClientSettings(ContextInterface $ctx);
/**
* Add options
@@ -134,6 +135,21 @@ public function addOption($oName, $oValue);
public function getOption($oName, $safe = false, $resolveUser = null);
/**
+ * @param ContextInterface $ctx
+ * @param string $oName
+ * @return mixed
+ * @throws \Pydio\Core\Exception\PydioException
+ */
+ public function getContextOption(ContextInterface $ctx, $oName);
+
+ /**
+ * @param string $oName
+ * @return mixed|string
+ * @throws \Exception
+ */
+ public function getSafeOption($oName);
+
+ /**
* Get the options that already have a value
* @return array
*/
@@ -239,17 +239,7 @@ public function getMergedRole();
* @return AJXP_Role
*/
public function getPersonalRole();
-
- /**
- * @param bool $resolveAsParent
- */
- public function setResolveAsParent($resolveAsParent);
-
- /**
- * @return bool
- */
- public function getResolveAsParent();
-
+
/**
* @return bool
* @throws \Exception
@@ -234,7 +234,7 @@ private function initRepositoryPlugins($ctx){
$plugInstance = $this->getPluginByTypeName("access", $accessType);
// TRIGGER BEFORE INIT META
- $metaSources = $repository->getOption("META_SOURCES");
+ $metaSources = $repository->getContextOption($ctx, "META_SOURCES");
if (isSet($metaSources) && is_array($metaSources) && count($metaSources)) {
$keys = array_keys($metaSources);
foreach ($keys as $plugId) {
@@ -271,7 +271,7 @@ private function initRepositoryPlugins($ctx){
$this->setPluginUniqueActiveForType("access", $accessType);
// TRIGGER INIT META
- $metaSources = $repository->getOption("META_SOURCES");
+ $metaSources = $repository->getContextOption($ctx, "META_SOURCES");
if (isSet($metaSources) && is_array($metaSources) && count($metaSources)) {
$keys = array_keys($metaSources);
foreach ($keys as $plugId) {
@@ -225,36 +225,7 @@ public static function clearRememberCookie()
setcookie("AjaXplorer-remember", "", time()-3600, null, null, (isSet($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on"), true);
}
}
-
- public static function logTemporaryUser($parentUserId, $temporaryUserId)
- {
- $parentUserId = self::filterUserSensitivity($parentUserId);
- $temporaryUserId = self::filterUserSensitivity($temporaryUserId);
- $confDriver = ConfService::getConfStorageImpl();
- $parentUser = $confDriver->createUserObject($parentUserId);
- $temporaryUser = $confDriver->createUserObject($temporaryUserId);
- $temporaryUser->mergedRole = $parentUser->mergedRole;
- $temporaryUser->rights = $parentUser->rights;
- $temporaryUser->setGroupPath($parentUser->getGroupPath());
- $temporaryUser->setParent($parentUserId);
- $temporaryUser->setResolveAsParent(true);
- AJXP_Logger::info(__CLASS__,"Log in", array("temporary user" => $temporaryUserId, "owner" => $parentUserId));
- self::updateUser($temporaryUser);
- }
-
- public static function clearTemporaryUser($temporaryUserId)
- {
- AJXP_Logger::info(__CLASS__,"Log out", array("temporary user" => $temporaryUserId));
- if (isSet($_SESSION["AJXP_USER"]) || isSet(self::$currentUser)) {
- AJXP_Logger::info(__CLASS__, "Log Out", "");
- unset($_SESSION["AJXP_USER"]);
- if(isSet(self::$currentUser)) unset(self::$currentUser);
- if (ConfService::getCoreConf("SESSION_SET_CREDENTIALS", "auth")) {
- AJXP_Safe::clearCredentials();
- }
- }
- }
-
+
/**
* Log the user from its credentials
* @static
@@ -1137,28 +1108,7 @@ public static function filterPluginParameters($pluginId, $params, ContextInterfa
}
return $params;
}
-
- /**
- * @param String $pluginId
- * @param Repository $repository
- * @param String $optionName
- * @param bool $safe
- * @return Mixed
- */
- public static function getFilteredRepositoryOption($pluginId, $repository, $optionName, $safe = false){
- $logged = self::getLoggedUser();
- $test = null;
- if($logged != null){
- $test = $logged->mergedRole->filterParameterValue($pluginId, $optionName, $repository->getId(), null);
- if(!empty($test) && !$safe) $test = VarsFilter::filter($test);
- }
- if(empty($test)){
- return $repository->getOption($optionName, $safe);
- }else{
- return $test;
- }
- }
-
+
/**
* @param string $parentUserId
* @return AJXP_Role
@@ -1400,8 +1400,9 @@ public static function getCoreConf($varName, $coreType = "ajaxplorer")
$coreP = PluginsService::getInstance()->findPlugin("core", $coreType);
if($coreP === false) return null;
$confs = $coreP->getConfigs();
- $confs = AuthService::filterPluginParameters("core.".$coreType, $confs, Context::fromGlobalServices());
- return (isSet($confs[$varName]) ? VarsFilter::filter($confs[$varName]) : null);
+ $ctx = Context::fromGlobalServices();
+ $confs = AuthService::filterPluginParameters("core.".$coreType, $confs, $ctx);
+ return (isSet($confs[$varName]) ? VarsFilter::filter($confs[$varName], $ctx) : null);
}
/**
@@ -22,6 +22,7 @@
use Psr\Http\Message\UploadedFileInterface;
use Pydio\Access\Core\Model\Repository;
+use Pydio\Core\Model\Context;
use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Services\AuthService;
use Pydio\Core\Services\ConfService;
@@ -1396,7 +1397,7 @@ public static function isStream($path)
*/
public static function loadSerialFile($filePath, $skipCheck = false, $format="ser")
{
- $filePath = VarsFilter::filter($filePath);
+ $filePath = VarsFilter::filter($filePath, Context::fromGlobalServices());
$result = array();
if ($skipCheck) {
$fileLines = @file($filePath);
@@ -1430,7 +1431,7 @@ public static function saveSerialFile($filePath, $value, $createDir = true, $sil
if(!in_array($format, array("ser", "json"))){
throw new \Exception("Unsupported serialization format: ".$format);
}
- $filePath = VarsFilter::filter($filePath);
+ $filePath = VarsFilter::filter($filePath, Context::fromGlobalServices());
if ($createDir && !is_dir(dirname($filePath))) {
@mkdir(dirname($filePath), 0755, true);
if (!is_dir(dirname($filePath))) {
@@ -1847,7 +1848,7 @@ public static function cleanDibiDriverParameters($params)
}
foreach ($params as $k => $v) {
$explode = explode("_", $k, 2);
- $params[array_pop($explode)] = VarsFilter::filter($v);
+ $params[array_pop($explode)] = VarsFilter::filter($v, Context::fromGlobalServices());
unset($params[$k]);
}
}
Oops, something went wrong.

0 comments on commit 1e0dc69

Please sign in to comment.