diff options
author | Joas Schilling <coding@schilljs.com> | 2022-06-13 12:22:18 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-06-30 16:26:43 +0200 |
commit | a05e5f64ec9c14b7c17d3b9683c884b3a8ccdcea (patch) | |
tree | d7e93f18e977ed769ddba904085fd94373c1f1a5 /lib/Controller/PageController.php | |
parent | 3a9ed27c1df3ce7c3d0e3a7770f332f0d20a4b43 (diff) |
Show warning about the throttling
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Controller/PageController.php')
-rw-r--r-- | lib/Controller/PageController.php | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index e8d4beeb6..4334211bf 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace OCA\Talk\Controller; +use OC\Security\Bruteforce\Throttler; use OCA\Talk\AppInfo\Application; use OCA\Talk\Exceptions\ParticipantNotFoundException; use OCA\Talk\Exceptions\RoomNotFoundException; @@ -73,6 +74,7 @@ class PageController extends Controller { private INotificationManager $notificationManager; private IAppManager $appManager; private IRootFolder $rootFolder; + private Throttler $throttler; public function __construct(string $appName, IRequest $request, @@ -90,6 +92,7 @@ class PageController extends Controller { IInitialState $initialState, ICacheFactory $memcacheFactory, IRootFolder $rootFolder, + Throttler $throttler, Config $talkConfig, IConfig $serverConfig) { parent::__construct($appName, $request); @@ -107,6 +110,7 @@ class PageController extends Controller { $this->initialState = $initialState; $this->memcacheFactory = $memcacheFactory; $this->rootFolder = $rootFolder; + $this->throttler = $throttler; $this->talkConfig = $talkConfig; $this->serverConfig = $serverConfig; } @@ -229,9 +233,12 @@ class PageController extends Controller { $this->talkSession->setPasswordForRoom($token, $password); } else { $this->talkSession->removePasswordForRoom($token); + $showBruteForceWarning = $this->throttler->getDelay($this->request->getRemoteAddress(), 'talkRoomPassword') > 5000; + if ($passwordVerification['url'] === '') { $response = new TemplateResponse($this->appName, 'authenticate', [ 'wrongpw' => $password !== '', + 'showBruteForceWarning' => $showBruteForceWarning, ], 'guest'); } else { $response = new RedirectResponse($passwordVerification['url']); @@ -314,9 +321,12 @@ class PageController extends Controller { $this->talkSession->setPasswordForRoom($token, $password); } else { $this->talkSession->removePasswordForRoom($token); + $showBruteForceWarning = $this->throttler->getDelay($this->request->getRemoteAddress(), 'talkRoomPassword') > 5000; + if ($passwordVerification['url'] === '') { $response = new TemplateResponse($this->appName, 'authenticate', [ 'wrongpw' => $password !== '', + 'showBruteForceWarning' => $showBruteForceWarning, ], 'guest'); } else { $response = new RedirectResponse($passwordVerification['url']); |