Fingerprint Laravel is a package for integrating Fingerprint Server API into your Laravel application
MIT License
Fingerprint Laravel is a package for integrating Fingerprint Server API into your Laravel application with PHP SDK for Fingerprint Pro Server API. It provides HTTP middlewares to block bots, VPNs, Tor, and more based on Fingerprint Server API event response.
fingerprint
config file.Event
and Fingerprint
classes. Event
data class will auto-bind when a request with requestId
Fingerprint
class provides a fluent interface to interact with the Fingerprint Server API.You can install the package via Composer:
$ composer require erayaydin/fingerprint-laravel
Check installation with about command.
Publish the configuration file:
$ php artisan vendor:publish --tag=fingerprint-config
This will create a config/fingerprint.php file where you can set configurations.
By default, the package will use the
FINGERPRINT_PRO_SECRET_API_KEY
andFINGERPRINT_REGION
environment variables. You should specify these values in your.env
file. You can change the environment variable names in the configuration file after publishing it.
eu
/europe
, ap
/asia
, global
.The package provides several middleware to block different types of traffics:
fingerprint.bots
)fingerprint.incognito
)fingerprint.old-identification
)fingerprint.tor
)fingerprint.vpn
)fingerprint.confidence
)You can register these middleware in your bootstrap/app.php
file or use the provided middleware group fingerprint
in
routes or controllers.
To use the middleware group in a route:
Route::middleware(['fingerprint'])->group(function () {
// Request is valid!
});
Or you can use specific middlewares:
Route::middleware(['fingerprint.incognito', 'fingerprint.vpn'])->group(function () {
// User is not in incognito mode and not using VPN!
});
Use dependency injection to access the Event
data class in your controller or middleware:
class ExampleController extends Controller
{
public function store(Event $event)
{
ray($event->identification, $event->botD, $event->isTor, $event->isVPN);
}
}
Use dependency injection to access the Fingerprint
class in your controller or middleware:
class ExampleController extends Controller
{
public function store(Fingerprint $fingerprint)
{
ray($fingerprint->getEvent('requestId'));
}
}
The package integrates with Laravel's AboutCommand
to provide information about the fingerprinting configuration.
This is registered automatically.
$ php artisan about
...
Fingerprint Laravel .........................................................
API Key ...................................................... Not Configured
Bot Block ................................................ Enabled (Bad Bots)
Incognito Block ..................................................... Enabled
Min. Confidence ......................................................... 0.8
Old Identification ............................................... 10 seconds
Region ................................................................... eu
TOR Block ............................................. Enabled (if signaled)
VPN Block ........................................................... Enabled
Version ................................................ 1.0.0+no-version-set
You can run the tests with:
composer test
requestId
key.Visitor
model and migrations.HasVisitorId
trait to use with custom Eloquent models.Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.