when throttling is active, in addition to front-end pages, ACT requests returning json packets are also throttled.

Aperta
#5,190 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
50/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
php
Ambito
backend

Direzione di ricerca

Start by reading the throttling guard around line 340 of system/ee/libraries/Core.php, which currently excludes REQ == 'CP', and the banish() method in system/ee/libraries/Throttling.php that builds the current plain-text/404/redirect response. Reproduce with a low max_page_loads/time_interval pair, then hit an ACT endpoint with X-Requested-With: XMLHttpRequest to see the non-JSON body. Decide between the two proposed fixes on the thread — the simpler REQ == 'ACTION' && AJAX_REQUEST exclusion in Core.php, or a JSON 429 response in banish() — and verify AJAX-driven control panel elements no longer break; done means an AJAX ACT call gets a usable response instead of plain text.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Description of the problem
ExpressionEngine throttling currently applies to ACT requests and appears to return responses intended for normal page requests (plain text/redirect/404), even when the request is AJAX and expects JSON.

This causes AJAX driven elements in CP pages to fail when throttling is triggered.

This in turn causes problems for some add-ons (e.g. JCOGS Image Pro) that use ACT based AJAX requests to generate dynamic parts of some control panel pages.

A better response would be either for throttling to return an API-safe response to AJAX/JSON-accepting requests, or to simply allow ACT based AJAX requests to run.

How To Reproduce
Steps to reproduce the behaviour:

  1. Enable throttling in EE settings.
  2. Configure low values (example):
    • max_page_loads = 2
    • time_interval = 5
    • lockout_time = 30
  3. Call an ACT endpoint repeatedly using AJAX (X-Requested-With: XMLHttpRequest) expecting JSON.
  4. Observe that after threshold is exceeded, response body is plain text/404/redirect style rather than JSON.

Error Messages
Plaintext:"You have exceeded the allowed page load frequency."

Environment Details:

  • Version: 7.5.21
  • PHP Version 8.2.30.

Possible Solution
It appears that the throttling code makes no attempt to identify AJAX requests.

  • One solution would be to modify the banish() method in system/ee/libraries/Throttling.php to include a check to see if call being processed is both an ACT request (REQ='ACTION') and an AJAX request (AJAX_REQEST defined) and use this to generate a fourth type of output with appropriate HTTP headers and message body ... for example:
    • HTTP 429 Too Many Requests
    • Content-Type: application/json; charset=utf-8
    • JSON body with a stable error shape such as:
{
  "status": "error",
  "error": "Request throttled. Please try again later.",
  "error_code": "throttled"
} 
  • A second (better, and easier) solution would be to exclude AJAX based ACT from throttling - along lines of current exclusion of CP activities by changing the conditional on line 340 of system/ee/libraries/Core.php to include REQ='ACTION' and AJAX_REQEST - e.g. if (REQ != 'CP' && ! (REQ == 'ACTION' && AJAX_REQUEST)) {
Lingua principale
PHP
Stelle
505
Fork
135
Merge medio
3g 7h
PR unite (30g)
7

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ExpressionEngine/ExpressionEngine

Tutte le issue di ExpressionEngine/ExpressionEngine

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.