Skip to content

Commit

Permalink
Mjh/implement captcha (#1)
Browse files Browse the repository at this point in the history
* Added Captcha

* Currently creating.

* Implemented for mews

* Added Support for Mews

* Fix styling

* Finished updating instructions.

* Fix styling

---------

Co-authored-by: spam-n-eggs <[email protected]>
  • Loading branch information
spam-n-eggs and spam-n-eggs authored Jan 26, 2024
1 parent 2e4539b commit 786fa5f
Show file tree
Hide file tree
Showing 15 changed files with 4,062 additions and 19 deletions.
38 changes: 26 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@
[![Total Downloads](https://img.shields.io/packagist/dt/dominion-solutions/filament-captcha.svg?style=flat-square)](https://packagist.org/packages/dominion-solutions/filament-captcha)


CAPTCHA Support in Filament!

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
[Skip to Installation](#installation)

## Installation
### What Is CAPTCHA?
CAPTCHA stands for Completely Automated Public Turing test to tell Computers and Humans Apart. The goal of this package is to keep bots from being able to submit fake data on your forms. This should be the last (and not first) line of defense to keep bots from submitting garbage data to your unprotected forms.

You can install the package via composer:
### Why do I need it?
If you're using a public panel within your application to collect data, for example a comment box, or a lead funnel, it can be (at best) annoying or (worst) a security liability for bots to try to be able to submit data to a form.

```bash
composer require dominion-solutions/filament-captcha
```

You can publish and run the migrations with:
## Installation

You can install the package via composer:
```bash
php artisan vendor:publish --tag="filament-captcha-migrations"
php artisan migrate
composer require dominion-solutions/filament-captcha
```
You will also need a Captcha Provider. Filament Captcha supports the following providers:
|| Provider || Composer Package || Install Instructions ||
| ---------- | ---------------- | ---------------------- |
| {m’e} Web Studio Captcha | `composer require mews/captcha` | [https://github.com/mewebstudio/captcha?tab=readme-ov-file#installation](https://github.com/mewebstudio/captcha?tab=readme-ov-file#installation) |

You can publish the config file with:

Expand All @@ -40,14 +44,24 @@ This is the contents of the published config file:

```php
return [
'engine' => env('CAPTCHA_ENGINE', 'mews'),
];
```

## Usage

Usage with `mews/captcha`
```php
$filamentCaptcha = new DominionSolutions\FilamentCaptcha();
echo $filamentCaptcha->echoPhrase('Hello, DominionSolutions!');
public function form(Form $form): Form
{
return $form->schema([
Captcha::make('captcha')
->rules(['captcha'])
->required()
->validationMessages([
'captcha' => __('Captcha does not match the image'),
]),
]);
}
```

## Testing
Expand Down
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
],
"require": {
"php": "^8.1",
"filament/filament": "^3.2",
"filament/forms": "^3.0",
"spatie/laravel-package-tools": "^1.15.0",
"illuminate/contracts": "^10.0"
"illuminate/contracts": "^10.0",
"spatie/laravel-package-tools": "^1.15.0"
},
"require-dev": {
"laravel/pint": "^1.0",
Expand All @@ -38,6 +39,11 @@
"phpstan/phpstan-phpunit": "^1.0",
"spatie/laravel-ray": "^1.26"
},
"suggest": {
"scyllaly/hcaptcha": "Required for hCaptcha support",
"scyllaly/recaptcha": "Required for reCAPTCHA support",
"mews/captcha": "Required for Mews Captcha support"
},
"autoload": {
"psr-4": {
"DominionSolutions\\FilamentCaptcha\\": "src/",
Expand Down Expand Up @@ -75,4 +81,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
8 changes: 8 additions & 0 deletions config/filament-captcha.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

// config for DominionSolutions/FilamentCaptcha
return [
// The engine to use for captcha generation
// Currently supported engines are: mews
'engine' => env('CAPTCHA_ENGINE', 'mews'),
];
Loading

0 comments on commit 786fa5f

Please sign in to comment.