Skip to content

Conversation

@dingo-d
Copy link
Contributor

@dingo-d dingo-d commented Sep 22, 2025

Description

This PR is a port of #498 to v8 of the forms plugin. As mentioned in the original PR:

This PR largely refactors the entire Security namespace, and adds support for granular rate limits (per form), in addition to global rate limits.

TL;DR:

  • adds a new database table for rate limits
  • uses it in the Security class
  • adds a post meta to forms for granular rate limiting
  • adds a model for log entries
  • adds a cleanup service which tries to use Action Scheduler if available or just cleans up if not

Note: I started cleaning up the tests, but I think the automated tests should be refactored, as I keep getting failures like:

   WARN  Your XML configuration validates against a deprecated schema. Migrate your XML configuration using "--migrate-configuration"!

   Error 

  Interface "EightshiftFormsVendor\EightshiftLibs\Services\ServiceInterface" not found

  at src/Integrations/Goodbits/SettingsGoodbits.php:24
     20▕ 
     21▕ /**
     22▕  * SettingsGoodbits class.
     23▕  */
  ➜  24▕ class SettingsGoodbits extends AbstractSettingsIntegrations implements SettingGlobalInterface, ServiceInterface
     25▕ {
     26▕ 	/**
     27▕ 	 * Filter global settings key.
     28▕ 	 */

      +2 vendor frames 

  3   tests/Integrations/Goodbits/GoodbitsSettingsTest.php:19
      Composer\Autoload\ClassLoader::loadClass("EightshiftForms\Integrations\Goodbits\SettingsGoodbits")

dingo-d and others added 7 commits September 22, 2025 09:32
---------

Co-authored-by: Mario Borna Mjertan <[email protected]>
---------

Co-authored-by: Mario Borna Mjertan <[email protected]>
This will support a granular rate limiting based on the form ID.
We have methods that will write and read from the database,
and check if the rate limit was exceeded during request validation.
The rate limit can be set up from the settings.

---------

Co-authored-by: Mario Borna Mjertan <[email protected]>
---------

Co-authored-by: Mario Borna Mjertan <[email protected]>
Also cleaned the unused class imports in the Validator.php file.

---------

Co-authored-by: Mario Borna Mjertan <[email protected]>
@dingo-d dingo-d changed the title Backport granular rate limits Granular rate limits Sep 22, 2025
@mbmjertan
Copy link
Contributor

Forms also now have this: #522

Not sure how do these two compare.

@dingo-d
Copy link
Contributor Author

dingo-d commented Sep 22, 2025

Activity log shouldn't be the same as this. At least by the name 🤷🏼‍♂️

@iruzevic
Copy link
Member

tnx for the PR, I will try to merge this to the next release and see if there are any additional changes necessary.
For test, don't bother they are not working at all. We will fix them in the future release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants