Is it possible to add wildcard character (*) to Captcha points?

Created on 8 September 2023, over 1 year ago
Updated 31 July 2024, 6 months ago

Problem/Motivation

Hey guys. I've been using the Captcha module since D7 and I can only thank you.

I am currently working on upgrading a website from D7 to D9. On this website, there are more than 1500 nodes, divided into different types of content, with the possibility of sending content to third parties through the Forward module.

It turns out that leaving Forward forms open is not safe and I would like to prevent spam on these forms by adding Captcha challenges.

I found two alternatives to do this, which are the existing options in the Captcha module: i) Add CAPTCHA challenges in all forms; and ii) Create a Captcha point for each node with forwarding permission.

However, enabling CAPTCHA challenges for all forms, despite including Forward, is not feasible, as this action would include Captcha in unwanted places.

The most viable alternative, then, would be to create Captcha points. It turns out that I should include approximately 1500 points to add Captcha challenges to all forms.

So I would like to suggest and check the possibility of adding a wildcard character (*) to the Captcha points, a fact that could reduce the work of many people, in addition to the possibility of working in a more comprehensive and targeted way.

I started this issue by reading this other one:

https://www.drupal.org/project/captcha/issues/3005577 β†’

Steps to reproduce

I did a test with a Captcha point for Forward and it looked like this:

Form ID: forward_form_node_1212
Machine name: forward_form_node_1212

It worked perfectly.

Proposed resolution

I would like to know if there is a possibility for us to do this:

Form ID: forward_form_node_*
Machine name: forward_form_node_*

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Needs review

Version

2.0

Component

Miscellaneous

Created by

πŸ‡§πŸ‡·Brazil astutonet Sao Paulo, SP

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @astutonet
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Hi @astutonet I understand what you refer to, as I also ran into this, knowing the old Drupal 7 Captcha logics. Drupal 8+ Captcha works differently and I don't think the wildcard support will be possible, if I remember correctly. But happy to review community work here.

  • πŸ‡ΊπŸ‡ΈUnited States wylbur Minneapolis, Minnesota, USA

    I'll add another request for this feature. If you are adding webforms to nodes via layout builder, blocks, paragraphs, the webform ID changes:
    form id - webform_submission_contact_add_form
    becomes
    formid - webform_submission_contact_node_20139_add_form

    For now, we are enabling captcha on all forms, and setting permissions that all authenticated users can skip captchas.

  • First commit to issue fork.
  • Merge request !96Wildcard support for Captcha points. β†’ (Open) created by Ruuds
  • Pipeline finished with Success
    6 months ago
    Total: 305s
    #239434
  • πŸ‡³πŸ‡±Netherlands Ruuds

    So we also ran into this. I've created a MR which adds the ability to support wildcard for captcha points. It currently matches on the beginning of the form id, so `webform_submission` also matches `webform_submission_contact_add_form` when wildcards are enabled for the specific captcha point.

    Wildcard support is disabled by default and should be enabled on a captcha point base. I've also added a test to the CaptchaTest test class.

  • Status changed to Needs review 6 months ago
  • πŸ‡³πŸ‡±Netherlands Ruuds
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    @Ruuds jsut FYI: In contrast to the Drupal 7 version, these captcha points are no more that important!
    Captcha support is enabled in webform settings (if this wasn't just an example).

    Maybe you could add a further MR to add a description which points this out in the captcha point area? Webform e.g. is quite common!

Production build 0.71.5 2024