Skip to content

Commit

Permalink
Skip turnstile logic entirely if challenge is not possible
Browse files Browse the repository at this point in the history
  • Loading branch information
maccabeelevine committed Dec 5, 2024
1 parent 5113d43 commit 4168916
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions module/VuFind/src/VuFind/RateLimiter/RateLimiterManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ public function check(EventInterface $event): array
$limit = $limiter->consume(1);
if (
$limit->isAccepted() &&
($this->config['Policies'][$policyId]['turnstileRateLimiterSettings'] ?? false)
($this->config['Policies'][$policyId]['turnstileRateLimiterSettings'] ?? false) &&
$this->turnstile->isChallengeAllowed($event)
) {
$turnstileLimiter = ($this->rateLimiterFactoryCallback)(
$this->config,
Expand Down Expand Up @@ -192,8 +193,7 @@ public function check(EventInterface $event): array
if (!$priorTurnstileResult) {
$result['allow'] = false;
$result['message'] = $this->getTooManyRequestsResponseMessage($event, $result);
$result['presentTurnstileChallenge'] =
($priorTurnstileResult === null) && $this->turnstile->isChallengeAllowed($event);
$result['presentTurnstileChallenge'] = ($priorTurnstileResult === null);
return $result;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function isChallengeAllowed($event)
{
$routeMatch = $event->getRouteMatch();
$controller = $routeMatch?->getParam('controller') ?? '??';
if ('AJAX' === $controller || str_contains($controller, 'Api')) {
if ('AJAX' === $controller || 'Cover' === $controller || str_contains($controller, 'Api')) {
return false;
}
return true;
Expand Down

0 comments on commit 4168916

Please sign in to comment.