Skip to content

Configuration

phil/spam-protection-bundle

The alias is phil_spam_protection. Every key is optional.

phil_spam_protection:
    secret: '%kernel.secret%'
    timing: { minimum: 3, maximum: 3600 }
    proof_of_work: 12
    content: { maximum_length: 20000, maximum_links: 3, forbidden_terms: [], detect_gibberish: true }
    cache_pool: cache.app
    rate_limiter: null
KeyDefaultMeaning
secret%kernel.secret%Signs the tokens and keys the client hash; 16 bytes or more. Changing it invalidates the forms already rendered.
timing.minimum3The seconds a person takes at least to fill a form; a quicker submission raises too_fast. 0 turns it off.
timing.maximum3600The seconds after which a rendered form is stale; a later submission raises token_expired. Used tokens are kept as long.
proof_of_work12The bits of difficulty of the browser's proof; 0 to 24, 0 turning it off. Keep it at 16 or below on forms people fill (Proof of work).
content.maximum_length20000The characters a text may hold; a longer text raises too_long, and only its first maximum_length characters are read. An integer of 1 or more, or ~ for no bound.
content.maximum_links3The links a text may hold, each address counted once; an integer of 0 or more, or ~ for no limit.
content.forbidden_terms[]Whole words, or sequences of words, a text may not hold, compared without case, accents or the punctuation between words.
content.detect_gibberishtrueWhether a text of random characters is held.
cache_poolcache.appThe PSR-6 pool of used tokens. Give one that every web server shares.
rate_limiternullThe service id of a Symfony rate limiter factory — limiter.contact for framework.rate_limiter.contact —; none by default.
# a rate limit of 5 submissions per hour, per form and client
framework:
    rate_limiter:
        forms: { policy: fixed_window, limit: 5, interval: '1 hour' }

phil_spam_protection:
    rate_limiter: limiter.forms

Services

ServiceRole
Infrastructure\Cache\CacheUsedTokensThe used tokens in cache_pool.
Infrastructure\RateLimit\SymfonySubmissionRateLimiterThe rate limit, only when rate_limiter is set.
Application\SubmissionInspectorIssues and inspects, built by SubmissionInspector::configured() from the configuration's values; usable outside forms (Extension points).
Infrastructure\Http\ClientKeyThe keyed hash of the current request's client address.
Infrastructure\Form\SpamProtectionTypeExtensionThe spam_protection option, tagged form.type_extension; logs on the spam_protection channel.