aldryn-forms icon indicating copy to clipboard operation
aldryn-forms copied to clipboard

Add robot protection with hidden fields

Open Ichag opened this issue 8 years ago • 6 comments

Should we add something like this to the forms to raise validation errors if an bot is trying to fill out the form additional or instead if using captchas?

class UnfillableField(forms.CharField):
    """
    A CharField raising a `forms.ValidationError` when filled.

    hide this field with css! E.g.

        .invisifi { display: none; }
    """
    widget = forms.TextInput(attrs={'class': 'invisifi'})

    def clean(self, value):
        if value:
            raise forms.ValidationError('Unknown error')


class UnfillableHiddenField(UnfillableField):
    """
    Like `UnfillableField` but with a `forms.HiddenInput` widget instead.
    """
    widget = forms.HiddenInput()
    hidden_widget = forms.HiddenInput()

It could be added to the wizard as optional fields or can be rendered into any generated form.

Suggestions?

Ichag avatar May 07 '16 09:05 Ichag

@Ichag Hello, I think it's a good idea to provide some honeypot functionality. That said, I'm leaning more towards using a third party integration vs implementing it directly on the core of aldryn-forms, the same way captchas are implemented.

django-honeypot looks like a good option, would have to check which versions of Django it's compatible with to make sure it matches the ones we support.

czpython avatar May 07 '16 14:05 czpython

I'd much rather use a honeypot instead of using captcha... good call.

derek-adair avatar Sep 09 '17 16:09 derek-adair

Any news here?

wfehr avatar Nov 06 '19 11:11 wfehr

@yvladislav implemented it for one project by forking aldryn-forms. I can try to look into integrating it, although I wouldn't expect it to happen in the next 1-2 weeks.

viktor-yunenko avatar Nov 20 '19 17:11 viktor-yunenko

@yvladislav, I know that you don't have time for implementation right now, but perhaps you could at least post the code here?

viktor-yunenko avatar Apr 05 '20 11:04 viktor-yunenko

For those who are comfortable with recaptcha v3 there's a pypi plugin - aldryn-forms-recaptcha-plugin

viktor-yunenko avatar Apr 05 '20 11:04 viktor-yunenko