Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"recaptcha" plugin incompatible with django-recaptcha>=2.0.0 #253

Open
sveetch opened this issue Dec 1, 2020 · 10 comments
Open

"recaptcha" plugin incompatible with django-recaptcha>=2.0.0 #253

sveetch opened this issue Dec 1, 2020 · 10 comments

Comments

@sveetch
Copy link

sveetch commented Dec 1, 2020

Bug Report

Expected behavior/code
fobi.contrib.plugins.form_elements.security.recaptcha should be compatible with last django-recaptcha version.

Actual Behavior
django-recaptcha release 2.0.0 has made some breakward incompatible refactoring on widget:

django-recaptcha/django-recaptcha@0a46ba8#diff-038fe6799d7292706ae4b851dd2dd64165d8018e8610bb25452f3457d562774b

This leads to an error on this plugin which try to import the old widget name "ReCaptcha":

https://github.com/barseghyanartur/django-fobi/blob/master/src/fobi/contrib/plugins/form_elements/security/recaptcha/base.py#L24

Steps to Reproduce

  1. Install django-fobi and django-recaptcha
  2. Configure everything
  3. Load the development server
  4. Warnings from fobi about recaptcha installation is raised in output
  5. Usage of recaptcha plugin fail

Environment

Python==3.6.8
Django==2.2.17
django-fobi==0.16.4
django-recaptcha==2.0.6
@sveetch
Copy link
Author

sveetch commented Dec 1, 2020

@barseghyanartur hi, what is your opinion about a fix for this ?

Since django-recaptcha==1.4.0 has dropped support for Django<=1.11 but fobi still support it. Also the old ReCaptcha widget has been renamed ReCaptchaV2Checkbox but there is also a new widget ReCaptchaV3 introduced in 2.0.0 but this seems out of scope for the fix which is only about V2.

What do you think ?

@barseghyanartur
Copy link
Owner

barseghyanartur commented Dec 1, 2020

I think it's time to drop everything below Django 2.2.

If you have time to work on making recaptcha plugin working again, either with V2 or V3 (if you think V3 is a better alternative), please branch from v0.16.x. I'll prepare deprecation/fix release in the meanwhile (0.17.x) and merge your changes in. OK?

@sveetch
Copy link
Author

sveetch commented Dec 1, 2020

Seems ok, first i did want to use the V3 but there seems to have some minor bugs for now, since V2 is solid enough i will focus on it so it's reliable. So i will look at this for next week, starting on 0.16.x for recaptcha 2.0.6 and V2.

@barseghyanartur
Copy link
Owner

barseghyanartur commented Dec 1, 2020

BTW, are you aware of invisible_recaptcha? I liked that one all the most. :) It should, however, not stop us improving recaptcha. :)

@sveetch
Copy link
Author

sveetch commented Dec 1, 2020

Yeah i now about the invisible one, but never used it yet. By the way it seems this one should work, from the recaptcha diff i don't see any incompatible changes.

@barseghyanartur
Copy link
Owner

@sveetch:

Could you test the v0.17.x branch? Recaptcha plugin is fixed there.

@barseghyanartur
Copy link
Owner

@sveetch:

Ping.

@sveetch
Copy link
Author

sveetch commented Dec 19, 2020

@barseghyanartur Sorry for the delay.

I've just tried with your last commit (b393446) from branch https://github.com/barseghyanartur/django-fobi/tree/v0.17.x and it works well, not any error when creating new form with a recaptcha field, updating it and using the form in frontend.

Here is the environment for my tests:

Python==3.6.8
Django==2.2.17
django-fobi==0.16.4
django-recaptcha==2.0.6
django-cms==3.7.4

By the way, i wanted to test the invisible recaptcha as you talked before, with the same environment in a new form and it does not succeed to validate the captcha field, i got this error in my form when submiting everything correctly:

captcha: * Invisible reCAPTCHA validation error

As described from this plugin Readme i've added settings FOBI_PLUGIN_INVISIBLE_RECAPTCHA_SITE_**. In my development environment i used the same recaptcha development keys:

RECAPTCHA_PUBLIC_KEY = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'
RECAPTCHA_PRIVATE_KEY = '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'

FOBI_PLUGIN_INVISIBLE_RECAPTCHA_SITE_KEY = RECAPTCHA_PUBLIC_KEY
FOBI_PLUGIN_INVISIBLE_RECAPTCHA_SITE_SECRET = RECAPTCHA_PRIVATE_KEY

And my frontend have jQuery v3.5.1 and did not see any Javascript error or Django error logs.

@sveetch
Copy link
Author

sveetch commented Dec 19, 2020

Also you got some warnings from Python about deprecated \s escaping sequence in regex:

.envs/default/lib/python3.6/site-packages/fobi/base.py:1553
  /home/emencia/projects/respiragora/.envs/default/lib/python3.6/site-packages/fobi/base.py:1553: DeprecationWarning: invalid escape sequence \s
    initial = re.sub("{{\s+", "{{", initial)

.envs/default/lib/python3.6/site-packages/fobi/base.py:1554
  /home/emencia/projects/respiragora/.envs/default/lib/python3.6/site-packages/fobi/base.py:1554: DeprecationWarning: invalid escape sequence \s
    initial = re.sub("\s+}}", "}}", initial)

https://github.com/barseghyanartur/django-fobi/blob/master/src/fobi/base.py#L1553

However, feel free to close this issue if it's ok for you since original subject from this issue has been fixed.

@barseghyanartur
Copy link
Owner

@sveetch:
The original issue is fixed in 0.17. Let this stay open for a while, until I check/fix your additional findings.

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

No branches or pull requests

2 participants