From 624b03653defecc3e8ce706e0d2ba7bcadd39be7 Mon Sep 17 00:00:00 2001 From: David Torralbo Date: Sun, 24 May 2020 10:14:43 +0200 Subject: [PATCH 1/7] Delete Facade --- src/SimpleRecaptchaV3Facade.php | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 src/SimpleRecaptchaV3Facade.php diff --git a/src/SimpleRecaptchaV3Facade.php b/src/SimpleRecaptchaV3Facade.php deleted file mode 100644 index cd8deaf..0000000 --- a/src/SimpleRecaptchaV3Facade.php +++ /dev/null @@ -1,16 +0,0 @@ - Date: Sun, 24 May 2020 10:17:07 +0200 Subject: [PATCH 2/7] Update assets reference name --- src/SimpleRecaptchaV3ServiceProvider.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SimpleRecaptchaV3ServiceProvider.php b/src/SimpleRecaptchaV3ServiceProvider.php index ef1440c..5a13fe9 100644 --- a/src/SimpleRecaptchaV3ServiceProvider.php +++ b/src/SimpleRecaptchaV3ServiceProvider.php @@ -15,15 +15,15 @@ public function boot() if ($this->app->runningInConsole()) { $this->publishes([ __DIR__.'/../config/config.php' => config_path('simple-recaptcha-v3.php'), - ], 'simple-recaptcha-v3-config'); + ], 'config'); $this->publishes([ __DIR__.'/../resources/views' => resource_path('views/vendor/simple-recaptcha-v3'), - ], 'simple-recaptcha-v3-views'); + ], 'views'); $this->publishes([ __DIR__.'/../resources/lang' => resource_path('lang/vendor/simple-recaptcha-v3'), - ], 'simple-recaptcha-v3-lang'); + ], 'lang'); } Blade::directive('captcha', function ($action) { From 2b7b0922a090e7da5a2d1a2ebe18838090e79b64 Mon Sep 17 00:00:00 2001 From: David Torralbo Date: Sun, 24 May 2020 13:03:29 +0200 Subject: [PATCH 3/7] Update config file --- config/config.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/config/config.php b/config/config.php index 7add8bc..7904714 100644 --- a/config/config.php +++ b/config/config.php @@ -1,15 +1,35 @@ env('CAPTCHA_ENABLED', true), + + /* + * Set your captcha keys here. Get yours here https://www.google.com/recaptcha/admin + */ 'site_key' => env('CAPTCHA_SITE_KEY', ''), 'secret_key' => env('CAPTCHA_SECRET_KEY', ''), + + /* + * Minimum score you should get to get the form validated + */ 'minimum_score' => env('CAPTCHA_MINIMUM_SCORE', 0.5), + + /* + * Check if the hostname request is the same as the form validation one. + */ 'hostname_check' => env('CAPTCHA_HOSTNAME_CHECK', true), /* + * Turning this switch to true, will make captcha badge invisible. * Before hide badge, you may read https://developers.google.com/recaptcha/docs/faq#id-like-to-hide-the-recaptcha-badge.-what-is-allowed */ 'hide_badge' => env('CAPTCHA_HIDE_BADGE', false), + + /* + * By turning on this setting, captcha badge will prefer the navigator language. + */ 'prefer_navigator_language' => env('CAPTCHA_PREFER_NAVIGATOR_LANGUAGE', false), ]; From 888c06778eba315c1499cafd4b12fd393e21977d Mon Sep 17 00:00:00 2001 From: David Torralbo Date: Sun, 24 May 2020 13:14:37 +0200 Subject: [PATCH 4/7] Update readme --- README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 999a263..895e959 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Simple reCAPTCHA v3 integration [![Latest Version on Packagist](https://img.shields.io/packagist/v/torralbodavid/simple-recaptcha-v3.svg?style=flat-square)](https://packagist.org/packages/torralbodavid/simple-recaptcha-v3) -[![Build Status](https://img.shields.io/travis/torralbodavid/simple-recaptcha-v3/master.svg?style=flat-square)](https://travis-ci.org/torralbodavid/simple-recaptcha-v3) +[![Build Status](https://travis-ci.org/torralbodavid/simple-recaptcha-v3.svg?branch=master)](https://travis-ci.org/torralbodavid/simple-recaptcha-v3) [![StyleCI](https://github.styleci.io/repos/263758912/shield)](https://github.styleci.io/repos/263758912) [![Quality Score](https://img.shields.io/scrutinizer/g/torralbodavid/simple-recaptcha-v3.svg?style=flat-square)](https://scrutinizer-ci.com/g/torralbodavid/simple-recaptcha-v3) [![Total Downloads](https://img.shields.io/packagist/dt/torralbodavid/simple-recaptcha-v3.svg?style=flat-square)](https://packagist.org/packages/torralbodavid/simple-recaptcha-v3) @@ -18,7 +18,28 @@ composer require torralbodavid/simple-recaptcha-v3 ## Usage -1. To get started, you must include at the very bottom of your head tag from the pages you want to protect with reCaptcha, the `@captcha_init` blade directive. This will start loading Google reCAPTCHA API. +1. Set the following variables in your .env + +Override xxxxx with your reCaptcha v3 keys. Get yours [here](https://www.google.com/recaptcha/admin) + +``` +CAPTCHA_SITE_KEY=xxxxx +CAPTCHA_SECRET_KEY=xxxxx +``` + +Optionally, you can publish the config file of the package. You will be able to customize advanced settings, such as: + +* Disabling reCaptcha v3 +* Minimum score you should get in order to validate your form +* Hostname validation +* Hide reCaptcha badge +* Prefer navigator language on reCaptcha badge + +``` +php artisan vendor:publish --provider="Torralbodavid\SimpleRecaptchaV3\SimpleRecaptchaV3ServiceProvider" --tag=config +``` + +2. To get started, you must include at the very bottom of your head tag from the pages you want to protect with reCaptcha, the `@captcha_init` blade directive. This will start loading Google reCAPTCHA API. ```html @@ -30,7 +51,7 @@ composer require torralbodavid/simple-recaptcha-v3 ``` -2. Include below your form initialization tag, the `@captcha('xxxx')` blade directive. Replace xxxx with your desired [action](https://developers.google.com/recaptcha/docs/v3#actions). +3. Include below your form initialization tag, the `@captcha('xxxx')` blade directive. Replace xxxx with your desired [action](https://developers.google.com/recaptcha/docs/v3#actions). ```html
@@ -39,7 +60,7 @@ composer require torralbodavid/simple-recaptcha-v3
``` -3. To sum up, add the following rule on your form validation: +4. To sum up, add the following rule on your form validation: `'recaptcha_response' => new Captcha` @@ -56,6 +77,30 @@ $request->validate([ Have fun! +### Customize error messages + +You can customize reCaptcha v3 error messages by publishing the translations on your project. + +```bash +php artisan vendor:publish --provider="Torralbodavid\SimpleRecaptchaV3\SimpleRecaptchaV3ServiceProvider" --tag=lang +``` + +### Customize snippets + +You can customize @captcha() and @captcha_init snippets by publishing the views on your project + +```bash + php artisan vendor:publish --provider="Torralbodavid\SimpleRecaptchaV3\SimpleRecaptchaV3ServiceProvider" --tag=views +``` + +### Disable reCaptcha v3 integration in tests + +You can easily disable reCaptcha v3 integration in your tests by adding the following configuration on them + +```php + config()->set('simple-recaptcha-v3.active', false); +``` + ### Testing ``` bash From 25b07aa27c63e580da099aa7cb7aa4fdade6ac9e Mon Sep 17 00:00:00 2001 From: David Torralbo Date: Sun, 24 May 2020 13:17:19 +0200 Subject: [PATCH 5/7] Update readme by adding some tabulations --- README.md | 54 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 895e959..cce798e 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,8 @@ composer require torralbodavid/simple-recaptcha-v3 Override xxxxx with your reCaptcha v3 keys. Get yours [here](https://www.google.com/recaptcha/admin) ``` -CAPTCHA_SITE_KEY=xxxxx -CAPTCHA_SECRET_KEY=xxxxx + CAPTCHA_SITE_KEY=xxxxx + CAPTCHA_SECRET_KEY=xxxxx ``` Optionally, you can publish the config file of the package. You will be able to customize advanced settings, such as: @@ -36,53 +36,53 @@ Optionally, you can publish the config file of the package. You will be able to * Prefer navigator language on reCaptcha badge ``` -php artisan vendor:publish --provider="Torralbodavid\SimpleRecaptchaV3\SimpleRecaptchaV3ServiceProvider" --tag=config + php artisan vendor:publish --provider="Torralbodavid\SimpleRecaptchaV3\SimpleRecaptchaV3ServiceProvider" --tag=config ``` 2. To get started, you must include at the very bottom of your head tag from the pages you want to protect with reCaptcha, the `@captcha_init` blade directive. This will start loading Google reCAPTCHA API. ```html - - - ... - - @captcha_init - - + + + ... + + @captcha_init + + ``` 3. Include below your form initialization tag, the `@captcha('xxxx')` blade directive. Replace xxxx with your desired [action](https://developers.google.com/recaptcha/docs/v3#actions). ```html -
- @captcha('login') - ... -
+
+ @captcha('login') + ... +
``` 4. To sum up, add the following rule on your form validation: -`'recaptcha_response' => new Captcha` - ```php -use Torralbodavid\SimpleRecaptchaV3\Rules\Captcha; - -... + 'recaptcha_response' => new Captcha +``` -$request->validate([ +```php + use Torralbodavid\SimpleRecaptchaV3\Rules\Captcha; + ... - 'recaptcha_response' => new Captcha, -]); + + $request->validate([ + ... + 'recaptcha_response' => new Captcha, + ]); ``` -Have fun! - ### Customize error messages You can customize reCaptcha v3 error messages by publishing the translations on your project. ```bash -php artisan vendor:publish --provider="Torralbodavid\SimpleRecaptchaV3\SimpleRecaptchaV3ServiceProvider" --tag=lang + php artisan vendor:publish --provider="Torralbodavid\SimpleRecaptchaV3\SimpleRecaptchaV3ServiceProvider" --tag=lang ``` ### Customize snippets @@ -104,7 +104,7 @@ You can easily disable reCaptcha v3 integration in your tests by adding the foll ### Testing ``` bash -composer test + composer test ``` ### Changelog @@ -127,3 +127,5 @@ If you discover any security related issues, please email davidtorralboperez@gma ## License The MIT License (MIT). Please see [License File](LICENSE.md) for more information. + +Have fun! From 20e4d6739da6990fce471cb256ea0903220bb6c2 Mon Sep 17 00:00:00 2001 From: David Torralbo Date: Sun, 24 May 2020 13:18:09 +0200 Subject: [PATCH 6/7] Tabulation in installation instructions at readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cce798e..3a0578d 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ This repository contains simple reCAPTCHA v3 integration for your Laravel applic You can install the package via composer: ```bash -composer require torralbodavid/simple-recaptcha-v3 + composer require torralbodavid/simple-recaptcha-v3 ``` ## Usage From 24478ab5915a3dc2f4539ad14254ba1fc493aba2 Mon Sep 17 00:00:00 2001 From: David Torralbo Date: Sun, 24 May 2020 13:25:05 +0200 Subject: [PATCH 7/7] Update CHANGELOG.md --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 021bbb7..e5f33ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ All notable changes to `simple-recaptcha-v3` will be documented in this file +## 1.1.0 - 2020-05-24 + +### Updates +- Update assets reference name [3b95223](https://github.com/torralbodavid/simple-recaptcha-v3/commit/3b952237460a44d1a5b2eb446f87b7eca70fd30c) +- Update readme instructions [888c067](https://github.com/torralbodavid/simple-recaptcha-v3/commit/888c06778eba315c1499cafd4b12fd393e21977d) + +### Deletions +- Delete package facade [624b036](https://github.com/torralbodavid/simple-recaptcha-v3/commit/624b03653defecc3e8ce706e0d2ba7bcadd39be7) + ## 1.0.6 - 2020-05-23 - Stable release