josiasmontag / laravel-recaptchav3 Goto Github PK
View Code? Open in Web Editor NEWLaravel package for Google's Recaptcha V3
License: MIT License
Laravel package for Google's Recaptcha V3
License: MIT License
My server has Content Security Policy enabled, i want to initialize js code with a nonce to allow recaptcha script execution.
Google docs recommend use nonce: FAQ
Can be added a function called initJsNonce() or related?
/**
* @param string $nonce
* @return string
*/
public function initJsNonce(string $nonce): string
{
return '<script src="' . $this->origin . '/api.js?render=' . $this->sitekey . '" nonce="'.$nonce.'"></script>';
}
As workaround how can add/override RecaptchaV3 class to add this?
I'm not familiarized with Laravel Container to do that, if anyone can help me I would appreciate.
First of all, thanks for sharing this !
A good enhancement would be to hide the badge, and optionnally, show it when the users starts filling a protected form.
Is it possible to add an error message if the score is lower then required?
with use of the validator?
Hi Josias,
I pareciate your time to develop this package.
But now I'm trying to update guzzle on my own way and composer response:
josiasmontag/laravel-recaptchav3 0.3.0 requires guzzlehttp/guzzle ^6.2 -> found guzzlehttp/guzzle[6.2.0, ..., 6.5.x-dev] but it conflicts with your root composer.json require (7.0)
It is possible for you update guzzle?
Thx
Non-static method Lunaweb\RecaptchaV3\RecaptchaV3::verify() should not be called statically
$score = RecaptchaV3::verify($request->get('g-recaptcha-response'), 'register'); var_dump($score); die;
If i use 'g-recaptcha-response' => 'required|recaptchav3:vote,0.5',
I cant post anything, it seems it doesnt detect the module
Followed all the steps and installed one of my sites.
But ReCaptcha admin console displaying this statement.
did i miss anything?
How to override the main RecaptchaV3 class in laravel
Sometimes i see forms being submitted with no score that are not spam.
At the moment i receive my "failed" forms and add the score to check it.
$recaptcha_score = RecaptchaV3::verify($request->get('g-recaptcha-response'), 'contact_general');
Resulting in $recaptcha_score being empty (with Validator using 'g-recaptcha-response' => 'required').
Hi,
As I noticed, there is no support for localization, in order to show the widget in different languages depending on the application and the user's needs.
Thanks
Hi, please add support for the latest version of guzzlehttp/guzzle 7.0.1. I have Laravel 7 and PHP 7.3.21
I have this error in composer.
Using version ^0.5.0 for josiasmontag/laravel-recaptchav3
./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 josiasmontag/laravel-recaptchav3 ^0.5.0 -> satisfiable by josiasmontag/laravel-recaptchav3[0.5.0].
- Conclusion: remove guzzlehttp/guzzle 7.0.1
- Conclusion: don't install guzzlehttp/guzzle 7.0.1
- josiasmontag/laravel-recaptchav3 0.5.0 requires guzzlehttp/guzzle ^6.2 -> satisfiable by guzzlehttp/guzzle[6.2.0, 6.2.1, 6.2.2, 6.2.3, 6.3.0, 6.3.1, 6.3.2, 6.3.3, 6.4.0, 6.4.1, 6.5.0, 6.5.1, 6.5.2, 6.5.3, 6.5.4, 6.5.5].
- Can only install one of: guzzlehttp/guzzle[6.2.0, 7.0.1].
- Can only install one of: guzzlehttp/guzzle[6.2.1, 7.0.1].
- Can only install one of: guzzlehttp/guzzle[6.2.2, 7.0.1].
- Can only install one of: guzzlehttp/guzzle[6.2.3, 7.0.1].
- Can only install one of: guzzlehttp/guzzle[6.3.0, 7.0.1].
- Can only install one of: guzzlehttp/guzzle[6.3.1, 7.0.1].
- Can only install one of: guzzlehttp/guzzle[6.3.2, 7.0.1].
- Can only install one of: guzzlehttp/guzzle[6.3.3, 7.0.1].
- Can only install one of: guzzlehttp/guzzle[6.4.0, 7.0.1].
- Can only install one of: guzzlehttp/guzzle[6.4.1, 7.0.1].
- Can only install one of: guzzlehttp/guzzle[6.5.0, 7.0.1].
- Can only install one of: guzzlehttp/guzzle[6.5.1, 7.0.1].
- Can only install one of: guzzlehttp/guzzle[6.5.2, 7.0.1].
- Can only install one of: guzzlehttp/guzzle[6.5.3, 7.0.1].
- Can only install one of: guzzlehttp/guzzle[6.5.4, 7.0.1].
- Can only install one of: guzzlehttp/guzzle[6.5.5, 7.0.1].
- Installation request for guzzlehttp/guzzle (locked at 7.0.1) -> satisfiable by guzzlehttp/guzzle[7.0.1].
Installation failed, reverting ./composer.json to its original content.
hi,
how do i change the error message? it outputs this validation.recaptchav3
sorry, new to laravel.
Recently, after working fine for some time, the score returns null or simply the validation fails.
Ran some tests:
Locally score is detected fine, but validation fails anyway.
on Production, score is null and validation fails anyway.
Anyone else experiencing this?
Thanks.
use Lunaweb\RecaptchaV3\Facades\RecaptchaV3;
// RecaptchaV3::verify($token, $action)
$score = RecaptchaV3::verify($request->get('g-recaptcha-response'), 'register')
if($score > 0.7) {
// go
} elseif($score > 0.3) {
// require additional email verification
} else {
return abort(400, 'You are most likely a bot');
}
above code always returns false
Hello,
I really like this package. I had no problems setting it up and using it. But lately, the download of the recaptcha__en.js script from www.gstatic.com is the slowest resource that affects my site speed the most. Is it possible to defer the loading of this script?
Best Regards.
Hello, I'm starting with this and the config file publishing is not working.
The documentation says:
php artisan vendor:publish --provider="Lunaweb\RecaptchaV3\RecaptchaV3ServiceProvider"
but I only was able to publish it doing:
php artisan vendor:publish --provider="Lunaweb\RecaptchaV3\Providers\RecaptchaV3ServiceProvider"
Maybe the namespace is wrong or just the docs.
For Chinese visitors/sites, they don't have abilities to access www.google.com
for GFW reasons, but they can access recaptcha's domain www.recaptcha.net
eg
so, can you make captcha origin configurable?
laravel-recaptchav3/src/RecaptchaV3.php
Line 18 in e4224c9
laravel-recaptchav3/src/RecaptchaV3.php
Line 101 in e4224c9
Hi,
sometimes the page on my website loads slow, so some people push the button to submit to early, so they dont got an google token and the post fail, is it an option to make an callback function so, when it is loaded an callback will be fired, so i can enable the button?
When submitting the form getting this message The g-recaptcha-response field is required.
No matter what i do i always get:
Invalid action name, may only include "A-Za-z/_". Do not include user-specific information. And the form cannot be submitted.
It's rendered like this in the html
grecaptcha.ready(function() {
grecaptcha.execute('6LdC4jklAAAAAP7JF31jlY3AjXFEGtCxJxHZRjGf', {action: 'handle-form'}).then(function(token) {
document.getElementById('g-recaptcha-response-64234447bb0d9').value = token;
});
});
Any idea what's going wrong?
If you are on the page for too long, when you submit the form, there will be a timeout and the reCAPTCHA will not validate. Perhaps, adding a built in function that only sets the token when the form is submitted would solve the issue?
I've installed the package following documentation.
The recaptcha logo appears at the bottom of the page, but when I'm going to submit the form, it shows me
Field g-recaptcha-response is required
Also in the console appears this:
contact:280 Uncaught ReferenceError: grecaptcha is not defined
at contact:280
Every time a request is sent using ajax, and there is an error, just let it do it once, you have to reload the page to be able to use it again, because it returns the catpcha error. It should have a function to refresh the captcha.
I made a login where it returns if the person has active, double authentication, so if it returns yes, it should ask for the code on the same page, but it doesn't stop because if it sends the code at once, it should refresh.
Getting this error
How to use and set up with proxy needed? It's not have proxy set up option?
Hello my validation is still null.
Here is an error I get when submitting a form
Method Illuminate\Validation\Validator::validateRecaptchav3 does not exist
After some debugging, it seems the extend('recaptchav3'
of the provider is not called before the validation.
The only solution was to move the extend
code to my AppServiceProvider::boot
...
Note that I add the provider to my config/app.php
:
\Lunaweb\RecaptchaV3\Providers\RecaptchaV3ServiceProvider::class,
and that I ran a config:clear
and a cache:clear
.
If I add a die
in the RecaptchaV3ServiceProvider, it got executed when I load a page, but not when I post a form (the error above occurs before it can).
I'm new to laravel, so it's probably a mistake of mine, right ?
I dont want to take value(secret and site key) from env instead i am storing it in my mysql database table i want to take the key value from there
I'm new, and I don't know how to import this class to use Validator and RecaptchaV3.
Can you help me please.
Error:
Symfony\Component\Debug\Exception\FatalThrowableError
Class 'App\Http\Controllers\Validator' not found
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.