* @param IRequest $request
* @param IManager $shareManager
*/
- public function __construct($appName,
+ public function __construct(string $appName,
IRequest $request,
IManager $shareManager) {
parent::__construct($appName, $request);
/**
* @PublicPage
* @NoCSRFRequired
+ * @BruteForceProtection(action=shareinfo)
*
* @param string $t
* @param null $password
* @param null $dir
* @return JSONResponse
- * @throws ShareNotFound
*/
public function info($t, $password = null, $dir = null) {
try {
$share = $this->shareManager->getShareByToken($t);
} catch (ShareNotFound $e) {
- return new JSONResponse([], Http::STATUS_NOT_FOUND);
+ $response = new JSONResponse([], Http::STATUS_NOT_FOUND);
+ $response->throttle(['token' => $t]);
+ return $response;
}
if ($share->getPassword() && !$this->shareManager->checkPassword($share, $password)) {
- return new JSONResponse([], Http::STATUS_FORBIDDEN);
+ $response = new JSONResponse([], Http::STATUS_FORBIDDEN);
+ $response->throttle(['token' => $t]);
+ return $response;
}
if (!($share->getPermissions() & Constants::PERMISSION_READ)) {
- return new JSONResponse([], Http::STATUS_FORBIDDEN);
+ $response = new JSONResponse([], Http::STATUS_FORBIDDEN);
+ $response->throttle(['token' => $t]);
+ return $response;
}
$permissionMask = $share->getPermissions();
->willThrowException(new ShareNotFound());
$expected = new JSONResponse([], Http::STATUS_NOT_FOUND);
+ $expected->throttle(['token' => 'token']);
$this->assertEquals($expected, $this->controller->info('token'));
}
->willReturn(false);
$expected = new JSONResponse([], Http::STATUS_FORBIDDEN);
+ $expected->throttle(['token' => 'token']);
$this->assertEquals($expected, $this->controller->info('token', 'pass'));
}
->willReturn(true);
$expected = new JSONResponse([], Http::STATUS_FORBIDDEN);
+ $expected->throttle(['token' => 'token']);
$this->assertEquals($expected, $this->controller->info('token', 'pass'));
}