spryker-ufirst / second-factor-auth
该软件包最新版本(v2.1.0)没有提供许可信息。
为 Spryker ZED 提供的二次因素认证
v2.1.0
2023-04-04 09:26 UTC
Requires
- php: >=7.3
- bacon/bacon-qr-code: ^2.0
- pragmarx/google2fa: ^8.0
- spryker/ramsey-uuid: 1.0.0 || 2.0.0
- spryker/security: ^1.6.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-10 11:58:56 UTC
README
安装
composer require spryker-ufirst/second-factor-auth
一旦模块安装完成,请将 SecondFactorAuthorizationEventDispatcherPlugin
添加到数组的末尾的 EventDispatcherDependencyProvider::getEventDispatcherPlugins
class EventDispatcherDependencyProvider extends SprykerEventDispatcherDependencyProvider { /** * @return \Spryker\Shared\EventDispatcherExtension\Dependency\Plugin\EventDispatcherPluginInterface[] */ protected function getEventDispatcherPlugins(): array { return [ # ...other plugins new SecondFactorAuthorizationEventDispatcherPlugin(), ]; } }
并将 SprykerUFirst
命名空间添加到 config_default.php
$config[KernelConstants::CORE_NAMESPACES] = [ ... 'SprykerUFirst', ];
强制执行 2FA
您可以根据环境强制所有管理员用户进行二次因素认证。将以下行添加到您的 config_default.php
use SprykerUFirst\Shared\SecondFactorAuth\SecondFactorAuthConstants; ... $config[SecondFactorAuthConstants::SECOND_FACTOR_AUTH_REQUIRED] = true;
将 2FA 状态添加到用户表
为了在管理界面上查看每个用户的 2FA 状态(启用/禁用),将两个表格展开插件添加到您的项目空间中的 UserDependencyProvider
<?php namespace Pyz\Zed\User; use Spryker\Zed\User\UserDependencyProvider as SprykerUserDependencyProvider; use SprykerUFirst\Zed\SecondFactorAuth\Communication\Plugin\Table\SecondFactorAuthUserTableConfigExpanderPlugin; use SprykerUFirst\Zed\SecondFactorAuth\Communication\Plugin\Table\SecondFactorAuthUserTableDataExpanderPlugin; class UserDependencyProvider extends SprykerUserDependencyProvider { /** * @return \Spryker\Zed\UserExtension\Dependency\Plugin\UserTableDataExpanderPluginInterface[] */ protected function getUserTableDataExpanderPlugins(): array { return [ new SecondFactorAuthUserTableDataExpanderPlugin(), ]; } /** * @return \Spryker\Zed\UserExtension\Dependency\Plugin\UserTableConfigExpanderPluginInterface[] */ protected function getUserTableConfigExpanderPlugins(): array { return [ new SecondFactorAuthUserTableConfigExpanderPlugin(), ]; } }
将重置 2FA 列添加到用户表
为了在管理界面上查看带有重置每个用户二次因素认证按钮的重置 2FA 列,请将以下行添加到您的 config_default.php
use SprykerUFirst\Shared\SecondFactorAuth\SecondFactorAuthConstants; ... $config[SecondFactorAuthConstants::SHOW_SECOND_FACTOR_AUTH_RESET] = true;
如果此列已启用,我们建议通过添加规则允许它具有最高权限的角色
或者,如果整个 second-factor-auth
包允许,请将此规则添加到不应能够注销其他用户的角色。