Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lib/Controller/SignalingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@
use OCP\DB\Exception;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IRequest;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Security\Bruteforce\IThrottler;
use Psr\Log\LoggerInterface;

/**
Expand All @@ -72,7 +70,6 @@ class SignalingController extends OCSController {
public function __construct(
string $appName,
IRequest $request,
IConfig $serverConfig,
private Config $talkConfig,
private \OCA\Talk\Signaling\Manager $signalingManager,
private TalkSession $session,
Expand All @@ -86,7 +83,6 @@ public function __construct(
private IEventDispatcher $dispatcher,
private ITimeFactory $timeFactory,
private IClientService $clientService,
IThrottler $throttler,
private LoggerInterface $logger,
private ?string $userId,
) {
Expand Down
7 changes: 6 additions & 1 deletion lib/Middleware/InjectionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
use OCP\Federation\ICloudIdManager;
use OCP\IRequest;
use OCP\Security\Bruteforce\IThrottler;
use OCP\Security\Bruteforce\MaxDelayReached;

class InjectionMiddleware extends Middleware {
protected bool $isTalkFederation = false;
Expand Down Expand Up @@ -316,7 +317,11 @@ public function afterException($controller, $methodName, \Exception $exception):
$action = $protection->getAction();

if ('talkRoomToken' === $action) {
$this->throttler->sleepDelay($this->request->getRemoteAddress(), $action);
try {
$this->throttler->sleepDelayOrThrowOnMax($this->request->getRemoteAddress(), $action);
} catch (MaxDelayReached $e) {
throw new OCSException($e->getMessage(), Http::STATUS_TOO_MANY_REQUESTS);
}
$this->throttler->registerAttempt($action, $this->request->getRemoteAddress(), [
'token' => $this->request->getParam('token') ?? '',
]);
Expand Down
3 changes: 0 additions & 3 deletions tests/php/Controller/SignalingControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ public function setUp(): void {
$this->messages = $this->createMock(Messages::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->clientService = $this->createMock(IClientService::class);
$this->throttler = $this->createMock(IThrottler::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->recreateSignalingController();
}
Expand All @@ -145,7 +144,6 @@ private function recreateSignalingController() {
$this->controller = new CustomInputSignalingController(
'spreed',
$this->createMock(IRequest::class),
$this->serverConfig,
$this->config,
$this->signalingManager,
$this->session,
Expand All @@ -159,7 +157,6 @@ private function recreateSignalingController() {
$this->dispatcher,
$this->timeFactory,
$this->clientService,
$this->throttler,
$this->logger,
$this->userId
);
Expand Down