Download the PHP package florentingarnier/spam-protection-bundle without Composer

On this page you can find all versions of the php package florentingarnier/spam-protection-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package spam-protection-bundle

Spam Protection Bundle

CI Latest Version Total Downloads PHP Symfony

Symfony integration of florentingarnier/spam-protection, an invisible CAPTCHA alternative: a honeypot, single-use timed tokens, a proof of work solved by the browser, per-form rate limiting, IP reputation and gibberish detection. No third-party service, no puzzle for your visitors.

The bundle provides:

Using Sylius? See florentingarnier/sylius-spam-protection-plugin.

Requirements

Installation

If you do not use Symfony Flex, enable the bundle:

Configuration

Every option is optional. The defaults are:

Run bin/console config:dump-reference florentin_garnier_spam_protection to display this reference.

Usage

1. Add the field to a form

Option Default Description
protection_scope 'unknown' Identifies the form: tokens and rate limits are not shared between forms. Give each form its own scope.
content_fields [] Sibling fields whose free text is rejected when made of random characters, or when it links to another site from a datacenter, a VPN or Tor.

The field is not mapped. When a submission is rejected, the error florentin_garnier_spam_protection.invalid is added to the parent form, so it shows up with the global form errors.

A link in a content field is accepted from a normal IP address, whatever it points to. From a datacenter, a VPN or a Tor exit node, only links to the host of the request and to own_hosts are accepted: see the library.

2. Render it

The bundle registers a form theme: form_row() (and form_rest()) renders the fields inside a block that is hidden from both sighted users and screen readers.

If you render it with form_widget(), wrap it yourself in an element with hidden and aria-hidden="true".

3. Load the JavaScript solver

assets/spam-protection.js is an ES module. Once imported, it solves the proof of work of every protected form on the page when the form is submitted. It has no dependency.

With Webpack Encore, declare an alias and import it from your entry point:

Forms submitted with JavaScript

The solver ignores submissions whose default action was already prevented. A form sent with fetch() must solve the challenge itself before building its payload:

Tokens are single-use, so an error response must send fresh ones back. ChallengeRefresh builds the payload expected by refreshSpamProtection():

IP reputation lists

The command downloads every source and replaces the compiled lists atomically. If a source is unavailable or returns no usable range, the command fails and the previous lists are kept.

The default datacenter and VPN lists come from X4BNet/lists_vpn, which does not declare a license: they are downloaded at runtime and never distributed with this bundle. Replace them in sources if needed.

Logging

When MonologBundle is installed, every submission is logged on the spam_protection channel:

Event Level Context
spam_protection.accepted info form, method, path, ip_hash, user_agent_hash, ip_risk
spam_protection.rejected warning the same, plus reason

IP addresses and user agents are hashed with HMAC-SHA256 and secret: they cannot be read back, but the same visitor always gets the same hash. To write the channel to its own file:

Translations

The error message florentin_garnier_spam_protection.invalid is translated in English, French and German, in the messages domain. Override it in your application's translation files.

The rejection adds a FormError whose message is already translated, as form themes render it as it is. Its message template remains the key: test error.messageTemplate to recognize the rejection, for example in a template.

Production checklist

Testing

To test your own protected forms, use SpamProtectionTestHelper from the library.

Contributing

Contributions are welcome. Please read CONTRIBUTING.md and the Code of Conduct. Report security issues privately, as described in SECURITY.md.

License

Released under the MIT License.


All versions of spam-protection-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
florentingarnier/spam-protection Version ^0.3
psr/log Version ^2.0 || ^3.0
symfony/config Version ^5.4 || ^6.4 || ^7.4 || ^8.0
symfony/console Version ^5.4 || ^6.4 || ^7.4 || ^8.0
symfony/dependency-injection Version ^5.4 || ^6.4 || ^7.4 || ^8.0
symfony/form Version ^5.4 || ^6.4 || ^7.4 || ^8.0
symfony/http-client-contracts Version ^2.5 || ^3.0
symfony/http-foundation Version ^5.4 || ^6.4 || ^7.4 || ^8.0
symfony/http-kernel Version ^5.4 || ^6.4 || ^7.4 || ^8.0
symfony/lock Version ^5.4 || ^6.4 || ^7.4 || ^8.0
symfony/translation-contracts Version ^2.5 || ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package florentingarnier/spam-protection-bundle contains the following files

Loading the files please wait ...