diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2017-04-14 13:42:40 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2017-04-14 13:42:40 +0200 |
commit | 727688ebd9c7cdeea4495e93f11b7f7bef9af109 (patch) | |
tree | 9f04e334eee326ccd0397f73d5e757aeb603de40 /apps | |
parent | f40b9fa9bd03b9c9590976eefa21aba7085f32f2 (diff) | |
download | nextcloud-server-727688ebd9c7cdeea4495e93f11b7f7bef9af109.tar.gz nextcloud-server-727688ebd9c7cdeea4495e93f11b7f7bef9af109.zip |
Adjust existing bruteforce protection code
- Moves code to annotation
- Adds the `throttle()` call on the responses on existing annotations
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'apps')
4 files changed, 7 insertions, 5 deletions
diff --git a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php index 9f848fbbb78..5cdba0cfffd 100644 --- a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php +++ b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php @@ -148,10 +148,12 @@ class MountPublicLinkController extends Controller { $authenticated = $this->session->get('public_link_authenticated') === $share->getId() || $this->shareManager->checkPassword($share, $password); if (!empty($storedPassword) && !$authenticated ) { - return new JSONResponse( + $response = new JSONResponse( ['message' => 'No permission to access the share'], Http::STATUS_BAD_REQUEST ); + $response->throttle(); + return $response; } $share->setSharedWith($shareWith); diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 732a1d32ee7..759d5ee4163 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -182,7 +182,9 @@ class ShareController extends Controller { return new RedirectResponse($this->urlGenerator->linkToRoute('files_sharing.sharecontroller.showShare', array('token' => $token))); } - return new TemplateResponse($this->appName, 'authenticate', array('wrongpw' => true), 'guest'); + $response = new TemplateResponse($this->appName, 'authenticate', array('wrongpw' => true), 'guest'); + $response->throttle(); + return $response; } /** diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php index c9a1d5ecb24..62adca53f4c 100644 --- a/apps/files_sharing/tests/Controller/ShareControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php @@ -280,6 +280,7 @@ class ShareControllerTest extends \Test\TestCase { $response = $this->shareController->authenticate('token', 'invalidpassword'); $expectedResponse = new TemplateResponse($this->appName, 'authenticate', array('wrongpw' => true), 'guest'); + $expectedResponse->throttle(); $this->assertEquals($expectedResponse, $response); } diff --git a/apps/user_ldap/lib/Controller/ConfigAPIController.php b/apps/user_ldap/lib/Controller/ConfigAPIController.php index 7d51b0aafe4..54800ef24eb 100644 --- a/apps/user_ldap/lib/Controller/ConfigAPIController.php +++ b/apps/user_ldap/lib/Controller/ConfigAPIController.php @@ -25,7 +25,6 @@ namespace OCA\User_LDAP\Controller; use OC\CapabilitiesManager; use OC\Core\Controller\OCSController; -use OC\Security\Bruteforce\Throttler; use OC\Security\IdentityProof\Manager; use OCA\User_LDAP\Configuration; use OCA\User_LDAP\Helper; @@ -52,7 +51,6 @@ class ConfigAPIController extends OCSController { CapabilitiesManager $capabilitiesManager, IUserSession $userSession, IUserManager $userManager, - Throttler $throttler, Manager $keyManager, Helper $ldapHelper, ILogger $logger @@ -63,7 +61,6 @@ class ConfigAPIController extends OCSController { $capabilitiesManager, $userSession, $userManager, - $throttler, $keyManager ); |