Enhance the security of your network with an additional layer of protection.
New driver should be extended from humhub\modules\twofa\drivers\BaseDriver
in the folder drivers
.
Also new created driver should be added into array humhub\modules\twofa\Module->drivers
:
public $drivers = [
EmailDriver::class,
GoogleAuthenticatorDriver::class,
];
Default driver humhub\modules\twofa\Module->defaultDriver
is used for Users from enforced Groups:
public $defaultDriver = EmailDriver::class;
twofa.beforeCheck
The twofa.beforeCheck
event is triggered before a Two-Factor Authentication (2FA) check is performed.
Other modules can listen to this event and set $handled = true
to skip the 2FA check.
This mechanism allows disabling 2FA:
beforeAction()
methodbeforeAction()
methodbeforeAction()
Example:
Yii::$app->on('twofa.beforeCheck', function (Event $event) use ($action) {
$event->handled = $action->controller->id === 'some-controller'; // Will disable 2FA for `some-controller`
});