PHP code example of cloudrepublic / shield-totp-mfa
1. Go to this page and download the library: Download cloudrepublic/shield-totp-mfa 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/ */
public bool $stepUpRequiresEnrollment = true;
public string $stepUpEnrollRouteName = 'totp-settings-enroll'; // or
// 'mfa-settings-totp-enroll'
// if using shield-mfa-dispatcher
public array $proxyIPs = [
'10.0.1.200' => 'X-Forwarded-For', // your actual proxy's IP
'192.168.5.0/24' => 'X-Forwarded-For', // or a whole trusted subnet
];
public array $views = [
'totp_mfa_verify' => 'App\Views\auth\my_totp_verify',
// any keys you don't list keep using this package's default
];
php spark totp-mfa:setup
php spark key:generate
tests/TotpMfa/
Libraries/Base32Test.php <- pure codec round-trip, no DB/HTTP
Libraries/TotpTest.php <- self-consistency + official RFC 6238 vectors
Libraries/TotpIdentityStoreTest.php <- enrollment/confirm/disable, needs DB
Authentication/Actions/TotpMfaTest.php <- login verify, remember-device, forced enrollment
Authentication/Actions/TotpActivatorTest.php <- registration-time QR/confirm/skip
Filters/RequireFreshTotpTest.php <- step-up challenge freshness logic
LogoutTest.php <- sanity check, not a Shield logout re-test
sql
SELECT * FROM auth_remembered_devices WHERE user_id = <id>;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.