diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2017-01-04 15:33:45 +0300 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2017-01-04 23:23:26 +0300 |
commit | 0c11209d33178a93cb8229573c445b49eaf2326f (patch) | |
tree | e40556f372f312b128ae7208ad78bce523483e7e /apps/files_sharing/lib | |
parent | a45137bbca0bd79a6f20dafb72e1f30ebbb3ab8e (diff) |
allow to access mail shares even if public links are disabled
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r-- | apps/files_sharing/lib/AppInfo/Application.php | 4 | ||||
-rw-r--r-- | apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php | 30 |
2 files changed, 28 insertions, 6 deletions
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 922db7dac75..403d30ae2e6 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -111,7 +111,9 @@ class Application extends App { $c->query('AppName'), $server->getConfig(), $server->getAppManager(), - $c['ControllerMethodReflector'] + $c['ControllerMethodReflector'], + $server->getShareManager(), + $server->getRequest() ); }); diff --git a/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php b/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php index 7e9109bf2d1..5712b96b97d 100644 --- a/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php +++ b/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php @@ -25,6 +25,8 @@ namespace OCA\Files_Sharing\Middleware; +use OCA\Files_Sharing\Controller\ExternalSharesController; +use OCA\Files_Sharing\Controller\ShareController; use OCP\App\IAppManager; use OCP\AppFramework\Http\NotFoundResponse; use OCP\AppFramework\Middleware; @@ -33,6 +35,8 @@ use OCP\IConfig; use OCP\AppFramework\Utility\IControllerMethodReflector; use OCA\Files_Sharing\Exceptions\S2SException; use OCP\AppFramework\Http\JSONResponse; +use OCP\IRequest; +use OCP\Share\IManager; /** * Checks whether the "sharing check" is enabled @@ -49,21 +53,32 @@ class SharingCheckMiddleware extends Middleware { protected $appManager; /** @var IControllerMethodReflector */ protected $reflector; + /** @var IManager */ + protected $shareManager; + /** @var IRequest */ + protected $request; /*** * @param string $appName * @param IConfig $config * @param IAppManager $appManager + * @param IControllerMethodReflector $reflector + * @param IManager $shareManager + * @param IRequest $request */ public function __construct($appName, IConfig $config, IAppManager $appManager, - IControllerMethodReflector $reflector + IControllerMethodReflector $reflector, + IManager $shareManager, + IRequest $request ) { $this->appName = $appName; $this->config = $config; $this->appManager = $appManager; $this->reflector = $reflector; + $this->shareManager = $shareManager; + $this->request = $request; } /** @@ -72,18 +87,23 @@ class SharingCheckMiddleware extends Middleware { * @param \OCP\AppFramework\Controller $controller * @param string $methodName * @throws NotFoundException + * @throws S2SException */ public function beforeController($controller, $methodName) { if(!$this->isSharingEnabled()) { throw new NotFoundException('Sharing is disabled.'); } - if ($controller instanceof \OCA\Files_Sharing\Controller\ExternalSharesController && + if ($controller instanceof ExternalSharesController && !$this->externalSharesChecks()) { throw new S2SException('Federated sharing not allowed'); - } else if ($controller instanceof \OCA\Files_Sharing\Controller\ShareController && - !$this->isLinkSharingEnabled()) { - throw new NotFoundException('Link sharing is disabled'); + } else if ($controller instanceof ShareController) { + $token = $this->request->getParam('token'); + $share = $this->shareManager->getShareByToken($token); + if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK + && !$this->isLinkSharingEnabled()) { + throw new NotFoundException('Link sharing is disabled'); + } } } |