PHP code example of globus-studio / fingerprint

1. Go to this page and download the library: Download globus-studio/fingerprint library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

globus-studio / fingerprint example snippets




declare(strict_types=1);

use GlobusStudio\Fingerprint\Configuration\FingerprintConfig;
use GlobusStudio\Fingerprint\FingerprintBuilder;

$config = FingerprintConfig::balanced(
    secret: $_ENV['APP_FINGERPRINT_SECRET']
);

$result = FingerprintBuilder::fromGlobals($config)->build();

echo $result->id();
echo $result->confidence();

$config = FingerprintConfig::balanced($_ENV['APP_FINGERPRINT_SECRET'])
    ->withTrustedProxies(['10.0.0.0/8', '172.16.0.0/12'])
    ->withTrustedHeaders(['x-forwarded-for', 'x-forwarded-proto']);

$result = FingerprintBuilder::fromGlobals($config)
    ->withLogger($psrCompatibleLogger)
    ->build();

$match = $matcher->compare($currentFingerprint, $storedFingerprint);

if ($match->level()->isSuspicious()) {
    // Trigger step-up authentication or manual review.
}