framework
Browser fingerprinting in Laravel
Add browser fingerprinting and bot, disposable email and IP checks to a Laravel signup form: the SDK through Vite, one check call with the HTTP client, and trusted proxies.
This guide adds OpenFingerprint to a Laravel signup form. The browser runs the SDK, which posts its evidence to the API's public identify listener, and puts the identification ID it gets back in a hidden field; the controller sends the identification ID, the email address and the visitor's IP to the check API with your secret key, and decides what to do with the answer. The listener sees the browser connect, and your key never reaches the browser.
1. Install the SDK and add your key
Laravel builds its front end with Vite, so install the SDK with npm:
npm install @openfingerprint/sdkCreate a secret key under API keys in the dashboard, add it to .env and read it through config/services.php:
OPENFINGERPRINT_KEY=of_…// config/services.php
'openfingerprint' => [
'key' => env('OPENFINGERPRINT_KEY'),
],2. Identify in the browser
The Blade form has a hidden field for the identification ID:
<form id="signup" method="post" action="{{ route('signup') }}">
@csrf
<input type="email" name="email" required />
<input type="hidden" name="of_identification" />
<button>Sign up</button>
</form>In resources/js/app.js, start watching and collecting when the page loads and fill the fields before the form is sent. Collect only once your disclosure or consent requirements are met.
import { identify, watch } from '@openfingerprint/sdk';
const form = document.getElementById('signup');
if (form) {
watch();
const collecting = identify({ endpoint: 'https://events.openfingerprint.com/v1/identify' });
let ready = false;
form.addEventListener('submit', async (event) => {
if (ready) return;
event.preventDefault();
try {
const { identificationId } = await collecting;
form.elements.of_identification.value = identificationId ?? '';
} catch {}
ready = true;
form.requestSubmit();
});
}If posting fails, identificationId is null and the form still submits. The server omits that ID; email and IP checks continue, and browser evidence stays unknown, not suspicious. There is no local-evidence fallback. If your site sets a Content-Security-Policy, allow https://events.openfingerprint.com in connect-src.
3. Check on the server
The controller calls POST /v1/check with Laravel's HTTP client. The API never reads an IP from the connection: your server passes the address it saw, and $request->ip() is that address once your proxies are trusted. Behind a load balancer, trust it in bootstrap/app.php, so a forwarded address the browser sent isn't taken at face value:
->withMiddleware(function (Middleware $middleware) {
$middleware->trustProxies(at: ['10.0.0.0/8']); // your load balancer's addresses
})// app/Http/Controllers/SignupController.php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
class SignupController extends Controller
{
public function store(Request $request)
{
$data = $request->validate([
'email' => ['required', 'email'],
'of_identification' => ['nullable', 'string', 'size:22'],
]);
$result = rescue(fn () => Http::withHeaders([
'x-api-key' => config('services.openfingerprint.key'),
])->timeout(5)->post('https://api.openfingerprint.com/v1/check', [
'identificationId' => $data['of_identification'] ?? null,
'email' => $data['email'],
'ip' => $request->ip(),
])->throw()->json(), [], report: false);
if ($result['disposable'] ?? false) {
return back()->withErrors(['email' => 'Please use a permanent email address.']);
}
$verifyFirst = ($result['automation'] ?? false) || ($result['spoofing'] ?? false) || ($result['replayed'] ?? false) || ($result['tor'] ?? false);
// create the account, store $result['visitorId'] ?? null on it only when present, and ask for
// email verification before any free credits when $verifyFirst is true
return redirect()->route('welcome');
}
}rescue() returns [] when the check fails or times out, so signups keep working when the API can't be reached.
4. Decide
The response is flat: a key is present only when it is known, so a missing disposable means unknown, never "clean".
disposableis strong evidence: ask for another address.automation,spoofing(the browser's report contradicts its headers or TLS handshake, as when a script poses as a browser),replayed(the same identification looked up twice) andtorare reasons to ask for more proof, such as email verification or a challenge, not to block.behaviorlists input patterns sincewatch(), such asclicks_without_movement. Keyboard users, autofill and password managers match some of them, so treat them as context for your own rules.visitorIdis a random server-issued browser grouping, not a fingerprint hash. Store it only when present and count recent accounts with the same ID. It can split repeat visits or merge indistinguishable browsers; missing IDs stay unknown.identificationIdreferences one hour-long observation and is not the value to store on accounts.
The free trial abuse guide has an example policy, and the check API reference lists every key.
Self-hosting
The SDK and the check API are MIT licensed. To run the API yourself, follow Deploy with Helm, replace the URL with your own service, drop the x-api-key header, and point endpoint at your own mandatory public identify listener. Configure identify.origins and identify.certificates, and use TCP passthrough so it sees the browser's TLS handshake. The internal check API has no authentication, so keep it on a private network. To receive visitor IDs, configure PostgreSQL, apply the visitor migrations and keep the deployment namespace stable. A single-customer install can set postgres.visitorScope; shared hosts should require backend-derived customer scopes. See visitor IDs and scopes.