Skip to content

Fixes #5682 az_spam_prevention module with preconfigured captcha defaults#5684

Open
tadean wants to merge 9 commits into
mainfrom
issue/5682
Open

Fixes #5682 az_spam_prevention module with preconfigured captcha defaults#5684
tadean wants to merge 9 commits into
mainfrom
issue/5682

Conversation

@tadean

@tadean tadean commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Description

This PR introduces a new module az_spam_prevention, which contains preconfigured captcha defaults and a hook that adds captcha placements to all webforms.

This is done because the composition of webform's base form IDs do not allow a single captcha point to cover all webforms.

Release notes

An experimental module, `az_spam_prevention` has been added which contains pre-configured defaults for form captchas. It will add a captcha placement to all webforms when enabled. 

Related issues

#5682

How to test

  • Install site
  • drush en webform
  • create a webform, or use the built-in contact form that comes with webform
  • enable az_spam_prevention
  • view the webform as an admin user, verify a captcha is not shown
  • view the webform as an anonymous user, verify that the captcha is shown
  • verify that the captcha blocks submissions if the captcha is incorrect
  • Add a captcha element to the webform (via the webform elements) and verify that still only one captcha is shown.
  • Enable contact module, create a (non-webform) contact form category, and verify that the captcha is placed on the form via the captcha point that is part of this PR

Types of changes

Arizona Quickstart (install profile, custom modules, custom theme)

  • Patch release changes
    • Bug fix
    • Accessibility, performance, or security improvement
    • Critical institutional link or brand change
    • Adding experimental module
    • Update experimental module
  • Minor release changes
    • New feature
    • Breaking or visual change to existing behavior
    • Upgrade experimental module to stable
    • Enable existing module by default or database update
    • Non-critical brand change
    • New internal API or API improvement with backwards compatibility
    • Risky or disruptive cleanup to comply with coding standards
    • High-risk or disruptive change (requires upgrade path, risks regression, etc.)
  • Other or unknown
    • Other or unknown

Drupal core

  • Patch release changes
    • Security update
    • Patch level release (non-security bug-fix release)
    • Patch removal that's no longer necessary
  • Minor release changes
    • Major or minor level update
  • Other or unknown
    • Other or unknown

Drupal contrib projects

  • Patch release changes
    • Security update
    • Patch or minor level update
    • Add new module
    • Patch removal that's no longer necessary
  • Minor release changes
    • Major level update
  • Other or unknown
    • Other or unknown

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My change requires release notes.

@tadean tadean self-assigned this Jun 12, 2026
@tadean tadean added the high priority Must get done for this milestone label Jun 12, 2026
@tadean tadean requested a review from a team as a code owner June 12, 2026 15:32
@tadean tadean added the patch release Issues to be included in the next patch release label Jun 12, 2026
@tadean tadean requested a review from a team as a code owner June 12, 2026 15:32
@tadean tadean added usability Improvements to usability of Quickstart components needs discussion Further discussion required to determine requirements proposal Proposed change to how something works (usually larger or more fundamental than a feature request) release notes labels Jun 12, 2026
@tadean

tadean commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author
  • Discuss captcha defaults
  • Determine whether to backport
  • Fix issue where captcha is sometimes placed after submit button
  • Determine if we should give some roles the skip captcha permission (or if seeing the captcha is useful for them)

@tadean

tadean commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Known issue with this PR so far, in some cases the captcha can appear after the submit button. I think it would be good to resolve that before merging.

image

Comment thread modules/custom/az_spam_prevention/src/Hook/AZAntiSpamHooks.php
@tadean tadean moved this from Todo to Needs review in 3.4.1 bug-fix patch release Jun 12, 2026
@joeparsons joeparsons moved this from Needs review to In Progress in 3.4.1 bug-fix patch release Jun 12, 2026
@joeparsons joeparsons linked an issue Jun 12, 2026 that may be closed by this pull request
@tadean

tadean commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author
  • Added captcha point for core contact form.
  • Added a check for existing captcha elements
  • Gave authenticated user skip captcha permission

@tadean

tadean commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Added workaround to place captcha correctly, because _captcha_get_captcha_placement() doesn't fully understand how webforms actions work.

@tadean tadean moved this from In Progress to Needs review in 3.4.1 bug-fix patch release Jun 16, 2026
@az-digital-bot

Copy link
Copy Markdown
Contributor

Tugboat has finished building the preview for this pull request!

Link:

Dashboard:

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

Labels

high priority Must get done for this milestone needs discussion Further discussion required to determine requirements patch release Issues to be included in the next patch release proposal Proposed change to how something works (usually larger or more fundamental than a feature request) release notes usability Improvements to usability of Quickstart components

Projects

Status: Needs review

Development

Successfully merging this pull request may close these issues.

Module for configured spam prevention defaults

3 participants