PHP code example of laranex / laravel-biometric-auth
1. Go to this page and download the library: Download laranex/laravel-biometric-auth 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/ */
laranex / laravel-biometric-auth example snippets
return [
'table' => env('BIOMETRIC_AUTH_TABLE', 'biometrics'),
// You will need to be explicit about the encryption padding and hash algorithm when working with RSA keys.
// For the rest of the algorithms, the package will automatically detect with the help of phpseclib.
'rsa' => [
'encryption_padding' => \phpseclib3\Crypt\RSA::SIGNATURE_PKCS1,
'hash_algorithm' => 'sha256',
],
];
// Use Laranex\LaravelBiometricAuth\Traits\HasBiometrics in your Authenticable Model such as User, Admin
class User extends Authenticatable {
use Laranex\LaravelBiometricAuth\Traits\HasBiometrics;
}
// Register a new biometric
$user->createBiometric("Base 64 encoded public key");
// Create a challenge for biometric authentication
$biometric = Laranex\LaravelBiometricAuth\Facades\LaravelBiometricAuth::getBiometric("UUID of a biometric");
// Verify the signature
Laranex\LaravelBiometricAuth\Facades\LaravelBiometricAuth::verifyBiometric("UUID of a biometric", "Signature");
// Get the user of verified biometric key
$user = Biometric::find("UUID of a biometric")->instance;
// Revoke a biometric
$user->revokeBiometric("UUID of a biometric");