Coder Social home page Coder Social logo

contributte / recaptcha Goto Github PK

View Code? Open in Web Editor NEW
40.0 11.0 27.0 299 KB

:bangbang: Google reCAPTCHA (security) for Nette Framework \ Forms

Home Page: https://contributte.org/packages/contributte/reCAPTCHA.html

License: MIT License

PHP 88.36% JavaScript 8.09% Makefile 3.55%
recaptcha google-recaptcha nette-framework forms contributte nette

recaptcha's Introduction

Website 🚀 contributte.org | Contact 👨🏻‍💻 f3l1x.io | Twitter 🐦 @contributte

Usage

To install latest version of contributte/recaptcha use Composer.

composer require contributte/recaptcha

Documentation

For details on how to use this package, check out our documentation.

Versions

State Version Branch Nette PHP
dev ^4.1 master 3.1+ >=8.1
stable ^4.0 master 3.1+ >=8.1

Development

See how to contribute to this package. This package is currently maintained by these authors.


Consider to support contributte development team. Also thank you for using this package.

recaptcha's People

Contributors

adaamz avatar f3l1x avatar fvesely avatar gappa avatar janbarasek avatar jangalek avatar jankonas avatar jansramek avatar juniwalk avatar mabar avatar natocto avatar paveljurasek avatar pavelweirich avatar petrparolek avatar suchoproduction avatar xpavp03 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

recaptcha's Issues

Invisible recaptcha + webpack + live form

Hello guys, we want to use invisible reCaptcha, since the regular one is working perfectly. But we got following error from the compiled js script Nette is not defined.

Screenshot 2019-06-14 at 12 29 38

If I use the script the included directly in main.js with window.Nette or $.nette the form is sent but we don't get any response from Nette. We also have the form included in the snippet (#12).

main.js compiled with webpack

import 'recaptcha.invisible.js';

require('nette.ajax.js');

window.Nette = require('live-form-validation');
window.Nette.initOnLoad();

$.nette.init();
$.nette.ext('unique');

We have (but I tested with Nette 3.0 + reCaptcha 3.2 and it was the same problem).

  • Nette 2.4
  • contributte/recaptcha 3.1.0
  • PHP 7.2

Has anyone run into the same problem? Thank you

Missing setRequired(TRUE | FALSE) on field 'recaptcha' in form 'xxxForm'

$form->addRecaptcha() shows reCaptcha, but not validate it.
$form->addRecaptcha()->setMessage('Are you bot?'); triggers warning "Missing setRequired(TRUE | FALSE) on field 'recaptcha' in form 'xxxForm'"
$form->addRecaptcha()->setRequired(FALSE)->setMessage('Are you bot?'); doesnt validate.
$form->addRecaptcha()->setRequired(TRUE)->setMessage('Are you bot?'); doesnt show 'Are you bot?' but 'This field is required' if form is submited without checking reCaptcha.

Errors in the HTML validation of the component

The validator.w3.org is not happy how the reCAPTCHA is rendered.

  • Error: Attribute type not allowed on element div at this point.
  • Error: Attribute name not allowed on element div at this point.
  • Error: Attribute required not allowed on element div at this point.

It could be better to use a standard text input field, visually hidden to apply nette form rules.

Composer nechce nainstalovat contributte/recaptcha

Zdravim,
Mam problem s instalaciou contributte recaptcha po vlozeni composer require contributte/recaptcha mi zobrazi ze instalacia prebieha a nasledne vypise instalation failed composer.json vracia do povodneho stavu:

`
composer require contributte/recaptcha:3.4.0
./composer.json has been updated
Running composer update contributte/recaptcha
Loading composer repositories with package information
Updating dependencies
Lock file operations: 3 installs, 0 updates, 0 removals

  • Locking contributte/di (v0.5.1)
  • Locking contributte/recaptcha (v3.4.0)
  • Locking nette/forms (v3.0.7)
    Writing lock file
    Installing dependencies from lock file (including require-dev)
    Package operations: 3 installs, 0 updates, 0 removals
  • Installing nette/forms (v3.0.7): Extracting archive
  • Installing contributte/di (v0.5.1): Extracting archive
  • Installing contributte/recaptcha (v3.4.0): Extracting archive
    1 package suggestions were added by new dependencies, use composer suggest to see details.
    Generating autoload files

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

[ErrorException]
file_put_contents(C:\Users\OVDPOSRTrebišov\Desktop\snapbackuper-web\vendor\bin/tester): failed to open stream: No such file or directory

require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-scripts] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] []...
`

skusal som aj vyssiu verziu dev a tak isto rovnako. S contributte translation som nemal problem.
Dakujem za pomoc.

Configurable proxy

Hi, is it possible to make a configurable proxy? Our company policy will not allow that file_get_contents request.
Specifically, the file is ReCaptchaProvider.php, function makeRequest (), line 102.

Now I have to make a hard adjustment to:

$aContext = array(
	'http' => array(
		'proxy '=> 'proxyXYZ.de:8000',
		'request_fulluri' => true,
	),
);
$context = stream_context_create($aContext);

return @file_get_contents($this->buildUrl($params), false, $context);

Otherwise, the recaptcha always returns to me that I am a robot

Problém s validací

Zdravím
Dle dokumentace mám nasazenou reCEPTCHA
$form->addReCaptcha('recaptcha', $label = 'Captcha', $required = TRUE, $message = 'Nejsi robot?');
a latte
<div class="form-group"> <div n:name="recaptcha"></div> </div>
Ale problém je v tom že i když nezakliknu reCAPTCHA tak se mi odešle foirmulář a nevyskočí mi hláška Nejsi robot?

Proč?

Feature: invisible recaptcha

Hi! Thanks a lot, this is very helpful library. I have question. I need implement invisible recaptcha from Google. Can i do this with your library? ty 😄

Not, its Google magic https://www.google.com/recaptcha/intro/comingsoon/invisible.html
Docs: https://developers.google.com/recaptcha/docs/invisible

The library can already be used. I tried to implement it, but I could not teach her to communicate with netteForms.js so I used your solution. My only chance is that you manage your experience.

Undefined array key "score"

After updating to version 4.0.1, PHP throws this warning:

PHP Warning: Undefined array key "score" in .../vendor/contributte/recaptcha/src/ReCaptchaProvider.php:66

return $answer['success'] === true && $answer['score'] >= $this->minimalScore ? new ReCaptchaResponse(true) : new ReCaptchaResponse(false, $answer['error-codes'] ?? null);

Displaying error in invisible version

Hi,
When I display an error of a certain form field, I do sth like this $form['field_name']->error because I don't like displaying all errors at the top of the form as a list. So, I also want to display the error only for invisible recaptcha field. The error message is in global form errors array $form->errors but the array of errors for specific recaptcha field $form['recaptcha']->errors is empty. After debugging I know it is because InvisibleReCaptchaField extends for HiddenField.
Is there a way to get the error just for recaptcha?

minetro/recaptcha:~1.4.0 fpr Nette ~2.2.0

Zdravím,
akurát hľadám nejakú captchu pre projekt nad Nette ~2.2.0. To podľa dokumentácie znamená nainštalovať minetro/recaptcha:~1.4.0.
To som urobil ale vypadne mi z toho error:
"ReCaptchaExtension.php – Call to undefined method Nette\PhpGenerator\ClassType::getMethod()"

Podľa dokumentácie by to malo byť $initialize = $class->methods[‚initialize‘]; nie?

Keď som to fixol, tak to začalo fungovať.

Vulnerable to automated attacks when error message not set

Error message is not required (although mentioned in the examples), but when it is not set, the whole recaptcha can be bypassed by using curl for example.

These are the lines mentioned:

Should the functionality be dependant on setting the message?
Maybe set a default message or validate it regardless?

Schovávání prvku

Nette umožňuje zobrazit/schovat pole a jeho validační pravidla v závislosti na plnění podmínek.

ReCaptcha se sice při splnění podmínky správně nastavuje jako povinné pole, nicméně se javascriptově neschová.

$form->addCheckbox("registered","I already have an account.");
$form->addReCaptcha('recaptcha', 'Captcha', false)
	->setOption('id', 'recaptcha')
	->addConditionOn($this["registered"], Form::EQUAL, false)
		->setRequired()
		->toggle('recaptcha');

Narazil jsem na stejný problém u jiných prvků, když se přidá validační pravidlo na celý prvek a setRequired() se nastaví až podle podmínky. Například metoda addInteger() automaticky přidává pravidlo FORM::NUMERIC. Aby schovávání fungovalo, musel jsem použít metodu addText() a validační pravidlo přidat až po splnění podmínky.

Dalo by se toto opravit, aby bylo možné prvky s recaptchou schovat?

Invisible recaptcha in snippet

Hello if you put recaptcha control (or whole form) into AJAx snippet a redraw it, recaptcha is not visible. If you reload whole page everything is OK.

Use with Nette\Forms standalone

Hello, is it possible to use this extension with the standalone Nette\Forms? Without the whole framework.
I installed it via composer and tried adding it like

use Nette\Forms\Form,
Minetro\ReCaptcha\Forms,
Nette\Forms\Controls;

But I get an error: Exception: Call to undefined method Nette\Forms\Form::addReCaptcha(). (in /DATA/htdocs/vendor/nette/utils/src/Utils/ObjectMixin.php line 70)

my composer devs:

  "require": {
    "php": ">=5.3.8",
    "nette/forms": "^2.4",
    "minetro/recaptcha": "^2.0.0"
  },

actual PHP version is 5.7
Without adding recaptcha my form is working fine.

Validation does not fire alert when recaptcha not checked

Using Nette 2.2 and minetro/reCaptcha 1.4

Recaptcha renders correctly and blocks the form in calling it's succeed method but it does not alert the user in any way. I guess this is due to not filled data-nette-rules in recaptcha ?

Please help

Support reCAPTCHA v3 Actions

I would like to use it with actions but it looks like this feature is not supported, right?

<script>
  function onClick(e) {
    e.preventDefault();
    grecaptcha.ready(function() {
      grecaptcha.execute('reCAPTCHA_site_key', {action: 'SPECIFIC-ACTION'}).then(function(token) {
          // Add your logic to submit to your backend server here.
      });
    });
  }
</script>

PHP 8 compatibility

Hello,
I have a problem with PHP 8.0 and composer update. After update to PHP 8.0 the composer won't resolve the reCAPTCHA because:

- contributte/recaptcha[v3.3.0, ..., v3.3.1] require php ^7.2 -> your php version (8.0.0) does not satisfy that requirement.

I guess that the package is already PHP 8.0 compatible but the php ^7.2 requirement prevents the composer from its usage. Would it be possible to make a quick fix and release a version which will state a compatibility with PHP 8.0?

Thanks.

Render error with Tomaj\BootstrapRenderer

hi,
I have problem rendering on v. 2.0.0 with nette v2.4,
Form renderer: Tomaj \ BootstrapRenderer.

Div box is rendered with borders in front of reCaptcha box with wrong height ...
"<div class =" g-recaptcha form-control "autocomplete =" off "id =" frm-regForm-recaptcha "

If i remove form-control class, wotk fine, but how can I remove it on single control?

Thank you.

PS: On in 1.6 work fine ....

No way to set score threshold for invisible reCAPTCHA

Hi,
first of all, thank you for this package!

I was just wondering whether the score returned for invisible Captcha is checked in any way (I haven't found any in the code).
If I understand correctly success field means merely that the ReCaptcha challenge site matches the one associated with
the secret key. (https://developers.google.com/recaptcha/docs/v3#site_verify_response)

To verify that request didn't come from a bot, the returned score must be compared to an application-specific threshold, right?

ReCaptchaField: Fatal Error: Allowed memory size of 134217728 bytes exhausted

When I update the dependency on Nette / Forms 3.1, I get the following error on production:

Fatal Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in Recaptcha/src/Forms/ReCaptchaField.php:67

I only have the following information from Tracy (no more surviving in HTML file):

Snímek obrazovky 2021-01-21 v 11 24 13

Thanks.

Nette Configurator issue

Hi,
I have installed new release 1.6.1 (like ~1.6.0 in composer.json), and it throws me an error:
Syntax error unexpected ":" in ...

File: ...\cache\Nette.Configurator\Container_5c35485316.php:7855

7845:            $this->getService('tracy.bar')->addPanel(new Nette\Bridges\DITracy\ContainerPanel($this));
7846:            $this->getService(191);
7847:            header('X-Frame-Options: SAMEORIGIN');
7848:            header('X-Powered-By: Nette Framework');
7849:            header('Content-Type: text/html; charset=utf-8');
7850:            $this->getService('session.session')->start();
7851:            Tracy\Debugger::setLogger($this->getService('tracy.logger'));
7852:            if ($tmp = $this->getByType("Nette\Http\Session", FALSE)) { $tmp->start(); Tracy\Debugger::dispatch(); };
7853:            if (!class_exists('WebLoader\LoaderFactory', FALSE)) class_alias('WebLoader\Nette\LoaderFactory', 'WebLoader\LoaderFactory');
7854:            Minetro\Forms\reCAPTCHA\ReCaptchaBinding::bind('6LcYBgsUAAAAADhF7EVIrbDLCzjzsSZ6geiZhQoh');
7855:            :factory('6LcYBgsUAAAAADhF7EVIrbDLCzjzsSZ6geiZhQoh');
7856:        }

Version 1.6.0 is ok.

contributte reCAPTCHA nelze nainstalovat

Ahoj, stáhl jsem si přes composer poslední verzi nette (3,0). Při instalaci contributte recaptcha (composer) mi to hází chybu:

C:\xampp\htdocs\web-project>composer require contributte/recaptcha
Using version ^3.2 for contributte/recaptcha
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for contributte/recaptcha ^3.2 -> satisfiable by contributte/recaptcha[3.2.0].
- Conclusion: remove nette/utils v3.1.0
- Conclusion: don't install nette/utils v3.1.0
- contributte/recaptcha 3.2.0 requires nette/utils ~3.0.0 -> satisfiable by nette/utils[v3.0.0, v3.0.1, v3.0.2, v3.0.3].
- Can only install one of: nette/utils[v3.0.0, v3.1.0].
- Can only install one of: nette/utils[v3.0.1, v3.1.0].
- Can only install one of: nette/utils[v3.0.2, v3.1.0].
- Can only install one of: nette/utils[v3.0.3, v3.1.0].
- Installation request for nette/utils (locked at v3.1.0, required as ^3.0) -> satisfiable by nette/utils[v3.1.0].

Installation failed, reverting ./composer.json to its original content.

Co s tím?

Service of type IReCaptchaValidatorFactory not registered in DIC

Hi,
if I follow quickstart I get this error:
Service 'application.2': Service of type Minetro\Forms\reCAPTCHA\IReCaptchaValidatorFactory needed by App\Presenters\HomepagePresenter::__construct() not found. Did you register it in configuration file?
I have to solve it manually with adding implement to that Validator service

services:
    reCAPTCHA.validator:
        implement: Minetro\Forms\reCAPTCHA\IReCaptchaValidatorFactory

The problem is in DI extension, where setup of implement is missing.

$builder->addDefinition($this->prefix('validator'))
// ->setImplement('Minetro\Forms\reCAPTCHA\IReCaptchaValidatorFactory') missing
            ->setClass('Minetro\Forms\reCAPTCHA\ReCaptchaValidator', [$config['secretKey']]);

May I create pull requests in all versions? 1.5, 1.6, ...

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.