Giter Club home page Giter Club logo

jh_captcha's Introduction

TYPO3 Extension jh_captcha

TYPO3 StyleCI Total Downloads Monthly Downloads License

Use Google reCAPTCHA (v2/v3) in your own TYPO3 extensions, EXT:form, EXT:powermail and EXT:formhandler as spam protection.

Documentation

Installation

Composer

Do composer require haffner/jh_captcha in your composer based TYPO3 root.

TYPO3 Extension Repository (TER)

Download and install the extension from TER.

jh_captcha's People

Contributors

a-r-m-i-n avatar infabo avatar nullsub avatar svenlamprecht avatar tehtux avatar thommyhh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

jh_captcha's Issues

Fluid template files loaded from wrong path

Describe the bug
Typo3 loads jh_recaptcha fluid template files from the wrong path:

  • Actual location: (...)typo3conf/ext/jh_captcha/Resources/Private/Powermail/Partials/Form/Field/JhCaptchaRecaptcha.html
  • Location Typo3 uses (...)/typo3conf/ext/powermail/Resources/Private/Partials/Form/Field/JhCaptchaRecaptcha.html

Note that I used jh_recaptcha v3.0.3 and the issue is different from #10 .

Is this a configuration problem on my part or a bug?

To Reproduce
Steps to reproduce the behavior:

  1. Install jh_captcha
  2. Create a new form, with only 1 field of type jh_recaptcha
  3. Save form
  4. Visit form in frontend
  5. Frontend displays: "Oops, an error occurred!"
  6. Error logged to Typo3 Syslog:
    Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1225709595: The Fluid template files "/var/www/<removed by schuberttobias>/httpdocs/typo3conf/ext/powermail/Resources/Private/Partials/Form/Field/JhCaptchaRecaptcha.html", "/var/www/<removed by schuberttobias>/httpdocs/typo3conf/ext/powermail/Resources/Private/Partials/Form/Field/JhCaptchaRecaptcha" could not be loaded. | TYPO3Fluid\Fluid\View\Exception\InvalidTemplateResourceException thrown in file /var/www/<removed by schuberttobias>/typo3_src-9.5.19/vendor/typo3fluid/fluid/src/View/TemplatePaths.php in line 730. Requested URL: https://dev.<removed by schuberttobias>/kontakt.html

Expected behavior
Steps 1-4 identical as above
5. Frontend displays the form correctly

Affected versions

  • PHP: v7.2.24-0ubuntu0.18.04.6
  • TYPO3: 9.5.19
  • jh_captcha: 3.0.3
  • form/powermail/formhandler: powermail

Missing Typo3 10.4.x LTS Support

Support for 10.4 LTS is not given yet.

The following errors were found while trying to install "jh_captcha":
Your TYPO3 version is higher than this extension requires. It requires TYPO3 versions 8.7.0 - 9.5.99

score

would be great if you could also output the score when integrating in EXT:form. Then it would be easier to define a suitable score for v3.

Powermail partial not found (case-sensitive file systems)

Powermail partial not found on case-sensitive file systems...

Tue, 11 Dec 2018 17:31:15 +0100 [ALERT] request="c6628e87e38c1" component="TYPO3.CMS.Frontend.ContentObject.Exception.ProductionExceptionHandler": Oops, an error occurred! Code: 20181211173115adc18810 - {"exception":"TYPO3Fluid\\Fluid\\View\\Exception\\InvalidTemplateResourceException: The Fluid template files \"\/home\/typo3v8\/typo3conf\/ext\/jh_captcha\/Resources\/Private\/Powermail\/Partials\/Form\/Field\/JhCaptchaRecaptcha.html\", \"\/home\/typo3v8\/typo3conf\/ext\/jh_captcha\/Resources\/Private\/Powermail\/Partials\/Form\/Field\/JhCaptchaRecaptcha\", \"\/home\/typo3v8\/typo3conf\/ext\/powermail\/Resources\/Private\/Partials\/Form\/Field\/JhCaptchaRecaptcha.html\", \"\/home\/typo3v8\/typo3conf\/ext\/powermail\/Resources\/Private\/Partials\/Form\/Field\/JhCaptchaRecaptcha\" could not be loaded. in \/home\/typo3v8\/typo3_src-8.7.21\/vendor\/typo3fluid\/fluid\/src\/View\/TemplatePaths.php:730

Oops, an error occurred! Code: 201911251334528cc9d495 - contact form

Describe the bug
did not work for me with: Typo3 9.5.11 and Bootstrap Package https://extensions.typo3.org/extension/bootstrap_package/

To Reproduce
Steps to reproduce the behavior:

  1. Add Ext: jh_captcha
    add Parmeters

Mastertemplate

https://www.bilder-upload.eu/bild-b3d3c9-1574685814.png.html

Template from ContactForm

https://www.bilder-upload.eu/bild-6aeed9-1574691079.png.html

  1. create contact form

https://www.bilder-upload.eu/bild-a6f831-1574685684.png.html

  1. open the form in Frontend

https://www.bilder-upload.eu/bild-5f0f94-1574685864.png.html

  1. See error

Oops, an error occurred! Code: 201911251334528cc9d495

If I remove reCaptcha from Contact Form, the Contact Form works fine.

Expected behavior
A clear and concise description of what you expected to happen.

Affected versions

  • PHP: 7.3
  • TYPO3: 9.5.11
  • jh_captcha: 3.0.2
  • form: 9.5.11

Additional context
Add any other context about the problem here.

Please add reCAPTCHA configuration options in TypoScript

The badge <div class="grecaptcha-badge"> is shown in the bottom-right corner by default, but this conflicts usually with a scroll-to-top button, so both overlapping each other (an ugly workaround is to move-up the badge by CSS).

The Google reCAPTCHA doc says, it is possible to configure this badge with the options bottomright, bottomleft or inline (the last option will display a "protected by reCAPTCHA" badge inside the form)

Not sure if this option is available also for v3, but at least for v2:
https://developers.google.com/recaptcha/docs/invisible

Thanks!

Test powermail 5-7

Check functionality with powermail

  • 5.x
  • 6.x
  • 7.x

Add this to the documentation

ReflectionException: Class RecaptchaValidator does not exist

I try to use a TYPO3 form, which is shown in the frontend very well until I add the ReCaptcha field. Then I see an "Oops, an error occurred!" error in the template, and the log file says:

"Oops, an error occurred! Code: 201812041434354d1ed305 - {"exception":"ReflectionException: Class Haffner\JhCaptcha\Validation\Validator\RecaptchaValidator does not exist ...}

I quess it has something to do with the autoloading or class-map (TYPO3 9.5.1 and jh_captcha 3.0.0).

PS:
During writing this bug-report I found the mistake, its a tiny typo in the file
Configuration/Yaml/ReCaptcha/BaseSetup.yaml line 22, change the 'c' to capital 'C': Haffner\JhCaptcha\Validation\Validator\ReCaptchaValidator

Using this extension together with powermail and its confirmation page does not work.

Describe the bug
We are using this extension together with powermail and its confirmation page. The problem is, that the captcha is validated twice. Once after submitting the form and once after submitting the confirmation page.

There is an if condition at the start of Haffner\JhCaptcha\Validation\Validator\Powermail::spamCheck, to prevent multiple reCAPTCHA validations, but it's not working.

Also, loading the reCAPTCHA response from the form via GeneralUtility::_GP("g-recaptcha-response") does not work after submitting the confirmation page, because the parameter "g-recaptcha-response" does not exist in this case.

To Reproduce
Steps to reproduce the behavior:

  1. Create a powermail form with a jh_recaptcha field.
  2. Activate the confirmation page in the powermail plugin, which displays the form.
  3. Fill out the form in the frontend and submit. This will take you to the confirmation page. With this form submit, the reCAPTCHA will be validated for the first time.
  4. Submit the confirmation page. With this form submit, the reCAPTCHA will be validated for the second time, which will fail.

Expected behavior
The reCAPTCHA should only be validated after submitting the confirmation page.

Affected versions

  • PHP: 7.4
  • TYPO3: 10.4
  • jh_captcha: 4.0.0
  • powermail: 8.3.2

Our suggestion for fixing this bug
Change Haffner\JhCaptcha\Validation\Validator\Powermail::spamCheck to

    public function spamCheck(): bool
    {
        # Skip captcha check on confirmation page
        if (
               GeneralUtility::_GPmerged('tx_powermail_pi1')['action'] === 'confirmation' // This has to be "confirmation" not "create".
                && $this->settings['main']['confirmation'] === '1' // We enable the confirmation page via TypoScript. Generally speaking, using $this->settings should be better than using $this->flexForm.
        ) {
            return false;
        }

        foreach ($this->mail->getAnswers() as $answer) {
            if ($answer->getField()->getType() == 'JhCaptchaRecaptcha') {
                /** @var ReCaptchaValidator $reCaptchaValidator */
                $reCaptchaValidator = GeneralUtility::makeInstance(ReCaptchaValidator::class);
                $result = $reCaptchaValidator->validate($answer->getValue()); // Don't read the value from GeneralUtility::_GP, because there are no _GP parameters after submitting the confirmation page.
                if (!empty($result->getErrors())) {
                    return true;
                }
            }
        }

        return false;
    }

In Resources/Private/Powermail/Partials/Form/Field/JhCaptchaRecaptcha.html change the view helper call to:

<jhcaptcha:reCaptcha
    uid="{f:if(condition: '{field.uid}', then: 'f{field.uid}', else: '')}"
    name="tx_powermail_pi1[field][{field.marker}]"
    type="powermail"
/>

In Haffner\JhCaptcha\ViewHelpers\ReCaptchaViewHelper::initializeArguments add

$this->registerArgument('name', 'String', 'Name of the hidden input element', false);

In Haffner\JhCaptcha\ViewHelpers\ReCaptchaViewHelper::renderV3 change the if ($this->isPowermail()) to

if ($this->isPowermail()) {
    $name = $this->arguments['name'] ?? 'g-recaptcha-response';
    $captchaResponseField = '<input type="hidden" id="' . $captchaResponseId . '" name="' . $name . '">';
}

Thank you very much in advance, for fixing the bug :)

Powermail form sending even if the reCaptcha is not checked

I have problems with jh captcha on typo3 8.7.28 and 9.5.8 / powermail 7.3.1 / jh_captcha 3.0.1

When I fill a form, I can send it even if the captcha is not checked / validated. Have you ever had this problem and have a solution ?

Thank you in advance

Yaml config breaks on Case Sensitive

Line 22 in jh_captcha/Configuration/Yaml/ReCaptcha/BaseSetup.yaml

          implementationClassName: 'Haffner\JhCaptcha\Validation\Validator\RecaptchaValidator'

while the Class is called ReCaptchaValidator

This breaks on Case Sensitive File systems
Reproducable in master and 3.0.1

Add expired-callback integration in grecaptcha.render code?

I'm using last jh_captcha version to integrate reCatcha v2.
Code generated in ReCaptchaViewHelper.php already contains the callback initialisation function.

As mentionned by Google (https://developers.google.com/recaptcha/docs/display) a callback function could be called/defined when the captcha expires (no activity from the user), just adding 'expired-callback': in the grecaptcha.render(...) definition.

Do you think it would be possible to add this feature in future version of the extension?
Thanks a lot for your job.
Regards
Joel

Validation does not work with own extension

Describe the bug
When implementing jh_captcha in my own extension, I get this error: Validation failed while trying to call ...erController->showAction().

Affected versions

  • TYPO3: 10.4
  • jh_captcha: 4.0.0
    My own extension

If I remove "Validate" from the model, it works, but the captcha is obviously not validated.

Not GDPR compliant

The plugin allows google recaptcha to reload google fonts from google server.

This means that the plugin is no longer legally compliant and the websites that use the plugin can be warned.

Update TER Release

Describe the bug
In TYPO3 Extension Repository the latest version is 4.0.0, but the latest release of jh_captcha is 5.0.0

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://extensions.typo3.org/extension/jh_captcha
  2. Latest version is 4.0.0

Expected behavior
The latest version available should be 5.0.0

Affected versions

  • jh_captcha: 5

Old condition matching

Describe the bug
jh_captcha floods the error log with messages like this:

Tue, 03 Dec 2019 15:48:18 +0100 [WARNING] request="b113352c0c1c4" component="TYPO3.CMS.Frontend.Configuration.TypoScript.ConditionMatching.ConditionMatcher": Expression could not be parsed, fallback kicks in. It looks like an old condition with only one equal sign. - {"expression":"globalVar = LIT:2 = 3"}

To Reproduce
Steps to reproduce the behavior:

  1. Install jh_captcha
  2. Include typoscript template

Affected versions

  • PHP: 7.2
  • TYPO3: 9.5
  • jh_captcha: 3.0.2
  • form: Standard 9.5

Additional context
https://github.com/TehTux/jh_captcha/blob/develop/Configuration/TypoScript/setup.txt#L44

Cookie Consent Manager

To include ReCaptcha GDPR compliant, its required to avoid loading the script before the user gives consent.

Therefore it's required to change the script tag included by ReCaptchaViewHelper.

In our case (Consentmanager.net) we need to change the src attribute to cmp-src and add some additional attributes.

For V3 this looks like this:

<script type="text/plain" class="cmplazyload" data-cmp-vendor="s1409" data-cmp-src="https://www.google.com/rec..." ></script>

But this modification get lost, everytime the extension is updated. So it would be nice, if the script tag is created by an template or an TypoScript setting.

E.G.:
$settings['reCaptcha']['v3']['scriptTagTemplate'] => '<script src="###SRC###" ></script>'
changed to:
$settings['reCaptcha']['v3']['scriptTagTemplate'] => '<script type="text/plain" class="cmplazyload" data-cmp-vendor="s1409" data-cmp-src="###SRC###" ></script>'

Best regards
Bernd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.