PHP code example of sicaboy / laravel-mfa
1. Go to this page and download the library: Download sicaboy/laravel-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/ */
sicaboy / laravel-mfa example snippets
'providers' => [
// ...
Sicaboy\LaravelMFA\LaravelMFAServiceProvider::class,
],
// Protect individual routes
Route::get('/dashboard', 'DashboardController@index')->middleware('mfa');
// Protect route groups
Route::middleware(['mfa'])->group(function () {
Route::get('/admin', 'AdminController@index');
Route::get('/profile', 'ProfileController@show');
});
// For admin routes
Route::middleware(['mfa:admin'])->group(function () {
Route::get('/admin/dashboard', 'Admin\DashboardController@index');
});
return [
'default' => [
// Default configuration...
],
'group' => [
'admin' => [ // Example, when using middleware 'mfa:admin'. Attributes not mentioned will be inherit from `default` above
'login_route' => 'admin.login',
'auth_user_closure' => function() {
return \Encore\Admin\Facades\Admin::user();
},
],
'other_name' => [ // Middleware 'mfa:other_name'
...
]
],
];
'email' => [
'queue' => true, // Enable queue for background sending
'template' => 'laravel-mfa::emails.authentication-code',
'subject' => 'Your Authentication Code',
],
'code_expire_after_minutes' => 10, // Default: 10 minutes
return [
'default' => [
'email' => [
'queue' => true, // Enable queue processing
]
]
];
bash
php artisan vendor:publish --provider="Sicaboy\LaravelMFA\LaravelMFAServiceProvider"
bash
php artisan queue:work