Laravel - 在没有 Jetstream 的情况下实施 Fortify 双因素身份验证
Laravel - Implementing Fortify two-factor authentication without Jetstream
我正在努力弄清楚如何在不使用 Jetstream 的情况下实现 Laravel/Fortify (https://github.com/laravel/fortify) 提供的 2FA。目前没有关于如何操作的文档。
我在 config/fortify.php
中启用了 twoFactorAuthenication
'features' => [
// Features::registration(),
// Features::resetPasswords(),
// Features::emailVerification(),
// Features::updateProfileInformation(),
Features::updatePasswords(),
Features::twoFactorAuthentication([
'confirmPassword' => true,
]),
],
我已经在Providers\FortifyServerProvider
中注册了twoFactorChallengeView
public function boot()
{
Fortify::twoFactorChallengeView('auth.two-factor-challenge');
我正在测试登录的帐户在 two_factor_secret
和 two_factor_recovery_code
字段中设置了值
我什至将我的代码与使用 2FA 的工作应用程序(使用 Jetstream 的 Laravel 8 的全新安装)进行了比较,但我看不出配置有任何差异。
我能够成功进行身份验证,但从未触发 2FA 质询。
我错过了什么?
在文件 App\Models\User.php
use Laravel\Fortify\TwoFactorAuthenticatable;
class User extends Authenticatable
{
use TwoFactorAuthenticatable;
}
我正在努力弄清楚如何在不使用 Jetstream 的情况下实现 Laravel/Fortify (https://github.com/laravel/fortify) 提供的 2FA。目前没有关于如何操作的文档。
我在 config/fortify.php
twoFactorAuthenication
'features' => [
// Features::registration(),
// Features::resetPasswords(),
// Features::emailVerification(),
// Features::updateProfileInformation(),
Features::updatePasswords(),
Features::twoFactorAuthentication([
'confirmPassword' => true,
]),
],
我已经在Providers\FortifyServerProvider
twoFactorChallengeView
public function boot()
{
Fortify::twoFactorChallengeView('auth.two-factor-challenge');
我正在测试登录的帐户在 two_factor_secret
和 two_factor_recovery_code
字段中设置了值
我什至将我的代码与使用 2FA 的工作应用程序(使用 Jetstream 的 Laravel 8 的全新安装)进行了比较,但我看不出配置有任何差异。
我能够成功进行身份验证,但从未触发 2FA 质询。
我错过了什么?
在文件 App\Models\User.php
use Laravel\Fortify\TwoFactorAuthenticatable;
class User extends Authenticatable
{
use TwoFactorAuthenticatable;
}