Permalink
Browse files

Split ConfService/AuthService into smaller services

Stop filling fromGlobalServices, may still have some side-effects
Todo: rewrite DuoAuthFrontend by extending SessionLogin frontend (?)
Todo: Disclaimer probably broken, shares as well.
  • Loading branch information...
1 parent bdb12d3 commit a720a193d4cfb96b1e30fceb749e92373d99890c @cdujeu cdujeu committed Jun 9, 2016
Showing with 2,098 additions and 1,636 deletions.
  1. +33 −15 core/src/core/src/pydio/Core/Controller/Controller.php
  2. +2 −1 core/src/core/src/pydio/Core/Controller/HTMLWriter.php
  3. +11 −10 core/src/core/src/pydio/Core/Controller/XMLWriter.php
  4. +2 −1 core/src/core/src/pydio/Core/Exception/AuthRequiredException.php
  5. +2 −1 core/src/core/src/pydio/Core/Exception/PydioException.php
  6. +11 −11 core/src/core/src/pydio/Core/Http/Cli/AuthCliMiddleware.php
  7. +12 −8 core/src/core/src/pydio/Core/Http/Dav/AuthBackendBasic.php
  8. +11 −7 core/src/core/src/pydio/Core/Http/Dav/AuthBackendDigest.php
  9. +4 −3 core/src/core/src/pydio/Core/Http/Dav/DAVServer.php
  10. +4 −2 core/src/core/src/pydio/Core/Http/Dav/RootCollection.php
  11. +111 −23 core/src/core/src/pydio/Core/Http/Middleware/AuthMiddleware.php
  12. +10 −0 core/src/core/src/pydio/Core/Http/Middleware/SessionMiddleware.php
  13. +19 −9 core/src/core/src/pydio/Core/Http/Rest/RestAuthMiddleware.php
  14. +11 −2 core/src/core/src/pydio/Core/Http/Server.php
  15. +4 −3 core/src/core/src/pydio/Core/Model/Context.php
  16. +149 −0 core/src/core/src/pydio/Core/Model/FilteredRepositoriesList.php
  17. +6 −0 core/src/core/src/pydio/Core/Model/UserInterface.php
  18. +1 −1 core/src/core/src/pydio/Core/PluginFramework/Plugin.php
  19. +9 −7 core/src/core/src/pydio/Core/PluginFramework/PluginsService.php
  20. +17 −54 core/src/core/src/pydio/Core/Services/AuthService.php
  21. +59 −1,012 core/src/core/src/pydio/Core/Services/ConfService.php
  22. +235 −0 core/src/core/src/pydio/Core/Services/LocaleService.php
  23. +46 −0 core/src/core/src/pydio/Core/Services/RepositoriesCache.php
  24. +507 −0 core/src/core/src/pydio/Core/Services/RepositoryService.php
  25. +2 −2 core/src/core/src/pydio/Core/Services/RolesService.php
  26. +71 −1 core/src/core/src/pydio/Core/Services/SessionService.php
  27. +81 −8 core/src/core/src/pydio/Core/Services/UsersService.php
  28. +4 −1 core/src/core/src/pydio/Core/Utils/BruteForceHelper.php
  29. +8 −0 core/src/core/src/pydio/Core/Utils/CookiesHelper.php
  30. +2 −1 core/src/core/src/pydio/Core/Utils/JSPacker.php
  31. +1 −1 core/src/core/src/pydio/Core/Utils/PydioSdkGenerator.php
  32. +13 −11 core/src/core/src/pydio/Core/Utils/Utils.php
  33. +95 −53 core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php
  34. +8 −8 core/src/plugins/access.ajxp_user/class.UserDashboardDriver.php
  35. +2 −1 core/src/plugins/access.dropbox/class.dropboxWrapper.php
  36. +26 −22 core/src/plugins/access.fs/class.fsAccessDriver.php
  37. +1 −1 core/src/plugins/access.fs/test.fsAccess.php
  38. +2 −1 core/src/plugins/access.ftp/class.ftpAccessDriver.php
  39. +7 −3 core/src/plugins/access.inbox/class.inboxAccessDriver.php
  40. +1 −2 core/src/plugins/access.mysql/class.mysqlAccessDriver.php
  41. +2 −2 core/src/plugins/action.cart/class.CartManager.php
  42. +2 −1 core/src/plugins/action.compression/class.PluginCompression.php
  43. +3 −3 core/src/plugins/action.powerfs/class.PowerFSController.php
  44. +6 −5 core/src/plugins/action.scheduler/class.AjxpScheduler.php
  45. +9 −7 core/src/plugins/action.share/src/Legacy/LegacyPubliclet.php
  46. +3 −2 core/src/plugins/action.share/src/Model/CompositeShare.php
  47. +6 −4 core/src/plugins/action.share/src/Model/ShareLink.php
  48. +34 −31 core/src/plugins/action.share/src/ShareCenter.php
  49. +2 −1 core/src/plugins/action.share/src/Store/ShareMetaManager.php
  50. +10 −8 core/src/plugins/action.share/src/Store/ShareRightsManager.php
  51. +19 −17 core/src/plugins/action.share/src/Store/ShareStore.php
  52. +8 −6 core/src/plugins/action.share/src/View/MinisiteRenderer.php
  53. +3 −2 core/src/plugins/action.share/src/View/PublicAccessManager.php
  54. +2 −1 core/src/plugins/action.timestamp/class.TimestampCreator.php
  55. +3 −2 core/src/plugins/action.updater/class.AjaXplorerUpgrader.php
  56. +2 −2 core/src/plugins/action.updater/class.UpdateController.php
  57. +3 −3 core/src/plugins/auth.multi/class.multiAuthDriver.php
  58. +14 −13 core/src/plugins/auth.remote/glueCode.php
  59. +11 −3 core/src/plugins/auth.remote_ajxp/class.remote_ajxpAuthDriver.php
  60. +2 −1 core/src/plugins/auth.smb/class.smbAuthDriver.php
  61. +10 −3 core/src/plugins/authfront.cas/class.CasAuthFrontend.php
  62. +8 −5 core/src/plugins/authfront.cyphered/class.CypheredAuthFrontend.php
  63. +11 −5 core/src/plugins/authfront.http_basic/class.BasicHttpAuthFrontend.php
  64. +7 −3 core/src/plugins/authfront.http_server/class.ServerHttpAuthFrontend.php
  65. +8 −3 core/src/plugins/authfront.keystore/class.KeystoreAuthFrontend.php
  66. +40 −18 core/src/plugins/authfront.session_login/class.SessionLoginFrontend.php
  67. +6 −5 core/src/plugins/boot.conf/class.BootConfLoader.php
  68. +3 −2 core/src/plugins/conf.serial/class.serialConfDriver.php
  69. +0 −1 core/src/plugins/conf.sql/class.AJXP_SqlUser.php
  70. +3 −2 core/src/plugins/conf.sql/class.sqlConfDriver.php
  71. +3 −2 core/src/plugins/core.access/src/AJXP_MetaStreamWrapper.php
  72. +6 −4 core/src/plugins/core.access/src/AbstractAccessDriver.php
  73. +10 −10 core/src/plugins/core.access/src/Model/AJXP_Node.php
  74. +2 −1 core/src/plugins/core.access/src/Model/NodesDiff.php
  75. +9 −7 core/src/plugins/core.access/src/Model/Repository.php
  76. +2 −1 core/src/plugins/core.access/src/Stream/AuthWrapper.php
  77. +2 −1 core/src/plugins/core.access/src/Stream/OAuthWrapper.php
  78. +2 −1 core/src/plugins/core.access/src/Stream/PathWrapper.php
  79. +2 −1 core/src/plugins/core.auth/class.CoreAuthLoader.php
  80. +3 −2 core/src/plugins/core.authfront/class.FrontendsLoader.php
  81. +2 −1 core/src/plugins/core.cache/class.CoreCacheLoader.php
  82. +19 −8 core/src/plugins/core.conf/class.AbstractAjxpUser.php
  83. +27 −22 core/src/plugins/core.conf/class.AbstractConfDriver.php
  84. +2 −1 core/src/plugins/core.conf/class.CoreConfLoader.php
  85. +2 −1 core/src/plugins/core.index/class.CoreIndexer.php
  86. +13 −5 core/src/plugins/core.log/class.AJXP_Logger.php
  87. +1 −1 core/src/plugins/core.log/class.AbstractLogDriver.php
  88. +10 −7 core/src/plugins/core.mailer/class.AjxpMailer.php
  89. +2 −1 core/src/plugins/core.meta/class.AJXP_AbstractMetaSource.php
  90. +2 −3 core/src/plugins/core.mq/class.MqManager.php
  91. +8 −6 core/src/plugins/core.notifications/class.AJXP_Notification.php
  92. +7 −7 core/src/plugins/core.notifications/class.AJXP_NotificationCenter.php
  93. +2 −1 core/src/plugins/core.ocs/src/Model/RemoteShare.php
  94. +10 −8 core/src/plugins/core.ocs/src/OCSPlugin.php
  95. +13 −7 core/src/plugins/core.ocs/src/Server/Dav/AuthSharingBackend.php
  96. +2 −1 core/src/plugins/core.ocs/src/Server/Dav/Server.php
  97. +1 −1 core/src/plugins/core.tasks/src/TaskService.php
  98. +2 −1 core/src/plugins/editor.browser/class.FileMimeSender.php
  99. +5 −3 core/src/plugins/editor.eml/class.EmlParser.php
  100. +1 −2 core/src/plugins/editor.etherpad/class.EtherpadClient.php
  101. +2 −1 core/src/plugins/editor.pixlr/class.PixlrEditor.php
  102. +11 −13 core/src/plugins/gui.ajax/class.AJXP_ClientDriver.php
  103. +3 −3 core/src/plugins/gui.mobile/class.MobileGuiPlugin.php
  104. +3 −2 core/src/plugins/gui.user/class.UserGuiController.php
  105. +2 −1 core/src/plugins/index.elasticsearch/class.AjxpElasticSearch.php
  106. +14 −5 core/src/plugins/index.lucene/class.AjxpLuceneIndexer.php
  107. +9 −4 core/src/plugins/log.sql/class.sqlLogDriver.php
  108. +7 −4 core/src/plugins/log.syslog/class.sysLogDriver.php
  109. +5 −7 core/src/plugins/log.text/class.textLogDriver.php
  110. +6 −7 core/src/plugins/meta.comments/class.CommentsMetaManager.php
  111. +6 −5 core/src/plugins/meta.git/class.GitManager.php
  112. +4 −5 core/src/plugins/meta.quota/class.QuotaComputer.php
  113. +2 −1 core/src/plugins/meta.simple_lock/class.SimpleLockManager.php
  114. +3 −2 core/src/plugins/meta.svn/class.SvnManager.php
  115. +4 −5 core/src/plugins/meta.syncable/class.ChangesTracker.php
  116. +1 −2 core/src/plugins/meta.user/class.UserMetaManager.php
  117. +2 −2 core/src/plugins/uploader.html/class.SimpleUploadProcessor.php
  118. +2 −3 core/src/plugins/uploader.http/class.HttpDownloader.php
@@ -22,14 +22,14 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
+use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Core\Exception\ActionNotFoundException;
use Pydio\Core\Exception\AuthRequiredException;
use Pydio\Core\Exception\PydioException;
use Pydio\Auth\Core\AJXP_Safe;
use Pydio\Core\Model\Context;
use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Services;
-use Pydio\Core\Services\AuthService;
use Pydio\Core\Services\ConfService;
use Pydio\Core\PluginFramework\PluginsService;
use Pydio\Core\Services\UsersService;
@@ -67,13 +67,13 @@ class Controller
/**
* Initialize the queryable xPath object
* @static
+ * @param ContextInterface $ctx
* @param bool $useCache Whether to cache the registry version in a memory cache.
* @return \DOMXPath
*/
- private static function initXPath($useCache = false)
+ private static function initXPath($ctx, $useCache = false)
{
if (!isSet(self::$xPath)) {
- $ctx = Context::fromGlobalServices();
$registry = PluginsService::getInstance($ctx)->getFilteredXMLRegistry(false, false, $useCache);
self::$xPath = new \DOMXPath($registry);
}
@@ -94,9 +94,10 @@ public static function registryReset(){
public static function parseRestParameters(ServerRequestInterface &$request){
$actionName = $request->getAttribute("action");
$path = $request->getAttribute("rest_path");
+ $ctx = $request->getAttribute("ctx");
$reqParameters = $request->getParsedBody();
- $xPath = self::initXPath(true);
+ $xPath = self::initXPath($ctx, true);
$actions = $xPath->query("actions/action[@name='$actionName']");
if (!$actions->length) {
throw new ActionNotFoundException($actionName);
@@ -190,7 +191,8 @@ public static function checkParams(&$parameters, $callbackNode, $xPath)
public static function run(ServerRequestInterface $request, &$actionNode = null)
{
$actionName = $request->getAttribute("action");
- $xPath = self::initXPath(true);
+ $ctx = $request->getAttribute("ctx");
+ $xPath = self::initXPath($ctx, true);
if ($actionNode == null) {
$actions = $xPath->query("actions/action[@name='$actionName']");
if (!$actions->length) {
@@ -199,7 +201,6 @@ public static function run(ServerRequestInterface $request, &$actionNode = null)
$actionNode = $actions->item(0);
}
/** @var ContextInterface $ctx */
- $ctx = $request->getAttribute("ctx");
//Check Rights
if (UsersService::usersEnabled()) {
$loggedUser = $ctx->getUser();
@@ -211,9 +212,9 @@ public static function run(ServerRequestInterface $request, &$actionNode = null)
throw new AuthRequiredException("207");
}
if( Controller::actionNeedsRight($actionNode, $xPath, "read") &&
- ($loggedUser == null || !$loggedUser->canRead(ConfService::getCurrentRepositoryId().""))){
+ ($loggedUser == null || !$loggedUser->canRead($ctx->getRepositoryId().""))){
if($actionName == "ls" & $loggedUser!=null
- && $loggedUser->canWrite(ConfService::getCurrentRepositoryId()."")){
+ && $loggedUser->canWrite($ctx->getRepositoryId()."")){
// Special case of "write only" right : return empty listing, no auth error.
$response = new Response();
$response->getBody()->write(XMLWriter::wrapDocument(""));
@@ -223,7 +224,7 @@ public static function run(ServerRequestInterface $request, &$actionNode = null)
}
}
if( Controller::actionNeedsRight($actionNode, $xPath, "write") &&
- ($loggedUser == null || !$loggedUser->canWrite(ConfService::getCurrentRepositoryId().""))){
+ ($loggedUser == null || !$loggedUser->canWrite($ctx->getRepositoryId().""))){
throw new AuthRequiredException("207");
}
}
@@ -432,13 +433,14 @@ private static function appliesCondition($callback, $actionName, $httpVars, $fil
/**
* Applies a callback node
* @static
+ * @param ContextInterface $context
* @param \DOMElement|array $callback The DOM Node or directly an array of attributes
* @param null $variableArgs
* @param bool $defer
* @throws PydioException
* @return mixed
*/
- private static function applyCallback($callback, &$variableArgs, $defer = false)
+ private static function applyCallback($context, $callback, &$variableArgs, $defer = false)
{
//Processing
if(is_array($callback)){
@@ -448,7 +450,7 @@ private static function applyCallback($callback, &$variableArgs, $defer = false)
$plugId = $callback->getAttribute("pluginId");
$methodName = $callback->getAttribute("methodName");
}
- $plugInstance = PluginsService::findPluginById($plugId);
+ $plugInstance = PluginsService::getInstance($context)->getPluginById($plugId);
//return call_user_func(array($plugInstance, $methodName), $actionName, $httpVars, $fileVars);
// Do not use call_user_func, it cannot pass parameters by reference.
if (method_exists($plugInstance, $methodName)) {
@@ -532,6 +534,22 @@ private static function parseCallback($callback){
*/
public static function applyHook($hookName, $args, $forceNonDefer = false)
{
+ $findContext = null;
+ foreach ($args as $arg){
+ if($arg instanceof ContextInterface) {
+ $findContext = $arg;
+ break;
+ }else if($arg instanceof AJXP_Node){
+ $findContext = $arg->getContext();
+ break;
+ }
+ }
+ if($findContext == null){
+ $findContext = Context::emptyContext();
+ AJXP_Logger::debug("Controller", "Applying hook $hookName without context");
+ //throw new \Exception("No context found");
+ }
+
if(isSet(self::$hooksCache[$hookName])){
$hooks = self::$hooksCache[$hookName];
foreach($hooks as $hook){
@@ -542,11 +560,11 @@ public static function applyHook($hookName, $args, $forceNonDefer = false)
}
$defer = $hook["defer"];
if($defer && $forceNonDefer) $defer = false;
- self::applyCallback($hook, $args, $defer);
+ self::applyCallback($findContext, $hook, $args, $defer);
}
return;
}
- $xPath = self::initXPath(true);
+ $xPath = self::initXPath($findContext, true);
$callbacks = $xPath->query("hooks/serverCallback[@hookName='$hookName']");
if(!$callbacks->length) return ;
self::$hooksCache[$hookName] = array();
@@ -575,12 +593,12 @@ public static function applyHook($hookName, $args, $forceNonDefer = false)
if($defer && $forceNonDefer) $defer = false;
if($dontBreakOnException){
try{
- self::applyCallback($hookCallback, $args, $defer);
+ self::applyCallback($findContext, $hookCallback, $args, $defer);
}catch(\Exception $e){
AJXP_Logger::error("[Hook $hookName]", "[Callback ".$plugId.".".$methodName."]", $e->getMessage());
}
}else{
- self::applyCallback($hookCallback, $args, $defer);
+ self::applyCallback($findContext, $hookCallback, $args, $defer);
}
}
}
@@ -22,6 +22,7 @@
use Psr\Http\Message\ResponseInterface;
use Pydio\Core\Services\ConfService;
+use Pydio\Core\Services\LocaleService;
use Pydio\Core\Utils\TextEncoder;
defined('AJXP_EXEC') or die( 'Access not allowed');
@@ -42,7 +43,7 @@ class HTMLWriter
*/
public static function displayMessage($logMessage, $errorMessage)
{
- $mess = ConfService::getMessages();
+ $mess = LocaleService::getMessages();
echo "<div title=\"".$mess[98]."\" id=\"message_div\" onclick=\"closeMessageDiv();\" class=\"messageBox ".(isset($logMessage)?"logMessage":"errorMessage")."\"><table width=\"100%\"><tr><td style=\"width: 66%;\">".(isset($logMessage)?$logMessage:$errorMessage)."</td><td style=\"color: #999; text-align: right;padding-right: 10px; width: 30%;\"><i>".$mess[98]."</i></tr></table></div>";
echo "<script>tempoMessageDivClosing();</script>";
}
@@ -24,7 +24,7 @@
use Pydio\Access\Core\IAjxpWrapperProvider;
use Pydio\Core\Model\Context;
use Pydio\Core\Model\ContextInterface;
-use Pydio\Core\Model\RepositoryInterface;
+use Pydio\Core\Services\LocaleService;
use Pydio\Core\Services\UsersService;
use Pydio\Core\Utils\Utils;
use Pydio\Core\Services;
@@ -244,8 +244,8 @@ public static function renderAjxpNode($ajxpNode, $close = true, $print = true)
*/
public static function replaceAjxpXmlKeywords($xml, $stripSpaces = false)
{
- $messages = ConfService::getMessages();
- $confMessages = ConfService::getMessagesConf();
+ $messages = LocaleService::getMessages();
+ $confMessages = LocaleService::getConfigMessages();
$matches = array();
if (isSet($_SESSION["AJXP_SERVER_PREFIX_URI"])) {
//$xml = str_replace("AJXP_THEME_FOLDER", $_SESSION["AJXP_SERVER_PREFIX_URI"].AJXP_THEME_FOLDER, $xml);
@@ -266,7 +266,7 @@ public static function replaceAjxpXmlKeywords($xml, $stripSpaces = false)
}
$xml = str_replace("AJXP_REMOTE_AUTH", "false", $xml);
$xml = str_replace("AJXP_NOT_REMOTE_AUTH", "true", $xml);
- $xml = str_replace("AJXP_ALL_MESSAGES", "MessageHash=".json_encode(ConfService::getMessages()).";", $xml);
+ $xml = str_replace("AJXP_ALL_MESSAGES", "MessageHash=".json_encode(LocaleService::getMessages()).";", $xml);
if (preg_match_all("/AJXP_MESSAGE(\[.*?\])/", $xml, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
@@ -331,7 +331,7 @@ public static function writeNodesDiff($diffNodes, $print = false)
/**
* @var $ajxpNode \Pydio\Access\Core\Model\AJXP_Node
*/
- $mess = ConfService::getMessages();
+ $mess = LocaleService::getMessages();
$buffer = "<nodes_diff>";
if (isSet($diffNodes["REMOVE"]) && count($diffNodes["REMOVE"])) {
$buffer .= "<remove>";
@@ -423,14 +423,15 @@ public static function triggerBgJSAction($jsCode, $messageId, $print=true, $dela
* List all bookmmarks as XML
* @static
* @param $allBookmarks
- * @param RepositoryInterface $repository
+ * @param ContextInterface $context
* @param bool $print
* @param string $format legacy|node_list
* @return string
*/
- public static function writeBookmarks($allBookmarks, $repository, $print = true, $format = "legacy")
+ public static function writeBookmarks($allBookmarks, $context, $print = true, $format = "legacy")
{
$driver = false;
+ $repository = $context->getRepository();
if ($format == "node_list") {
$driver = $repository->getDriverInstance();
if (!($driver instanceof IAjxpWrapperProvider)) {
@@ -449,7 +450,7 @@ public static function writeBookmarks($allBookmarks, $repository, $print = true,
}
if ($format == "node_list") {
if ($driver) {
- $node = new AJXP_Node($driver->getResourceUrl($path));
+ $node = new AJXP_Node($context->getUrlBase().$path);
$buffer .= XMLWriter::renderAjxpNode($node, true, false);
} else {
$buffer .= XMLWriter::renderNode($path, $title, false, array('icon' => "mime_empty.png"), true, false);
@@ -564,7 +565,7 @@ public static function writeRepositoriesData(ContextInterface $ctx)
{
$loggedUser = $ctx->getUser();
$st = "<repositories>";
- $streams = ConfService::detectRepositoryStreams(false);
+ $streams = ConfService::detectRepositoryStreams($loggedUser, false);
$exposed = PluginsService::searchManifestsWithCache("//server_settings/param[contains(@scope,'repository') and @expose='true']", function($nodes){
$exposedNodes = [];
@@ -577,7 +578,7 @@ public static function writeRepositoriesData(ContextInterface $ctx)
return $exposedNodes;
});
- $accessible = ConfService::getAccessibleRepositories($loggedUser, false, false);
+ $accessible = UsersService::getRepositoriesForUser($loggedUser);
$inboxStatus = 0;
foreach($accessible as $repoId => $repoObject){
@@ -24,6 +24,7 @@
use Pydio\Core\Http\Response\JSONSerializableResponseChunk;
use Pydio\Core\Http\Response\XMLSerializableResponseChunk;
use Pydio\Core\Services\ConfService;
+use Pydio\Core\Services\LocaleService;
defined('AJXP_EXEC') or die('Access not allowed');
@@ -33,7 +34,7 @@ class AuthRequiredException extends PydioException implements XMLSerializableRes
public function __construct($messageId = "", $messageString = "")
{
if(!empty($messageId)){
- $mess = ConfService::getMessages();
+ $mess = LocaleService::getMessages();
if(isSet($mess[$messageId])) $messageString = $mess[$messageId];
}
parent::__construct($messageString, $messageId);
@@ -21,6 +21,7 @@
namespace Pydio\Core\Exception;
use Pydio\Core\Services\ConfService;
+use Pydio\Core\Services\LocaleService;
defined('AJXP_EXEC') or die( 'Access not allowed');
/**
@@ -35,7 +36,7 @@ class PydioException extends \Exception
public function __construct($messageString, $messageId = false, $errorCode = null)
{
if ($messageId !== false && class_exists("ConfService")) {
- $messages = ConfService::getMessages();
+ $messages = LocaleService::getMessages();
if (array_key_exists($messageId, $messages)) {
$messageString = $messages[$messageId];
} else {
@@ -25,14 +25,17 @@
use Pydio\Auth\Core\AJXP_Safe;
use Pydio\Core\Controller\Controller;
use Pydio\Core\Exception\AuthRequiredException;
+use Pydio\Core\Exception\LoginException;
use Pydio\Core\Http\Server;
use Pydio\Core\Model\Context;
use Pydio\Core\PluginFramework\PluginsService;
use Pydio\Core\Services\AuthService;
use Pydio\Core\Services\ConfService;
+use Pydio\Core\Services\RepositoryService;
use Pydio\Core\Services\RolesService;
use Pydio\Core\Services\UsersService;
use Pydio\Core\Utils\Utils;
+use Pydio\Log\Core\AJXP_Logger;
use Zend\Diactoros\Response;
defined('AJXP_EXEC') or die('Access not allowed');
@@ -57,9 +60,9 @@ public static function handleRequest(ServerRequestInterface $requestInterface, R
$optPass = $options["p"];
$optRepoId = $options["r"];
- $repository = ConfService::getRepositoryById($optRepoId);
+ $repository = RepositoryService::getRepositoryById($optRepoId);
if ($repository == null) {
- $repository = ConfService::getRepositoryByAlias($optRepoId);
+ $repository = RepositoryService::getRepositoryByAlias($optRepoId);
if ($repository != null) {
$optRepoId =($repository->isWriteable()?$repository->getUniqueId():$repository->getId());
}
@@ -139,14 +142,11 @@ public static function handleRequest(ServerRequestInterface $requestInterface, R
if ($seed != -1) {
$optPass = md5(md5($optPass).$seed);
}
- $loggingResult = AuthService::logUser($optUser, $optPass, isSet($optToken), false, $seed);
- if (isset($loggingResult) && $loggingResult != 1) {
+ try{
+ $loggedUser = AuthService::logUser($optUser, $optPass, isSet($optToken), false, $seed);
+ }catch (LoginException $l){
throw new AuthRequiredException();
}
- $loggedUser = AuthService::getLoggedUser();
- if($loggedUser == null) throw new AuthRequiredException();
-
-
} else {
throw new AuthRequiredException();
@@ -164,16 +164,15 @@ public static function handleRequest(ServerRequestInterface $requestInterface, R
AuthService::disconnect();
$responseInterface->getBody()->write("\n--- Impersonating user ".$impersonateUser);
try{
- AuthService::logUser($impersonateUser, "empty", true, false, "");
- $loggedUser = AuthService::getLoggedUser();
- if($loggedUser == null) continue;
+ $loggedUser = AuthService::logUser($impersonateUser, "empty", true, false, "");
ConfService::switchRootDir($optRepoId, true);
Controller::registryReset();
$subResponse = new Response();
$ctx = new Context();
$ctx->setUserObject($loggedUser);
$ctx->setRepositoryId($optRepoId);
$requestInterface = $requestInterface->withAttribute("ctx", $ctx);
+ AJXP_Logger::updateContext($ctx);
$subResponse = Server::callNextMiddleWareAndRewind(function($middleware){
return (is_array($middleware) && $middleware["0"] == "Pydio\\Core\\Http\\Cli\\AuthCliMiddleware" && $middleware[1] == "handleRequest");
@@ -200,6 +199,7 @@ public static function handleRequest(ServerRequestInterface $requestInterface, R
$ctx->setUserObject($loggedUser);
$ctx->setRepositoryId($optRepoId);
$requestInterface = $requestInterface->withAttribute("ctx", $ctx);
+ AJXP_Logger::updateContext($ctx);
return Server::callNextMiddleWare($requestInterface, $responseInterface, $next);
Oops, something went wrong.

0 comments on commit a720a19

Please sign in to comment.