mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Add support for global 2FA enforcement #349
This commit is contained in:
parent
375f715b78
commit
8b3cfc7a67
15 changed files with 85 additions and 54 deletions
|
|
@ -7,9 +7,9 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
{
|
||||
const
|
||||
NAME = 'Two Factor Authentication',
|
||||
VERSION = '2.13.3',
|
||||
RELEASE = '2022-03-04',
|
||||
REQUIRED = '2.13.2',
|
||||
VERSION = '2.15.0',
|
||||
RELEASE = '2022-04-25',
|
||||
REQUIRED = '2.15.0',
|
||||
CATEGORY = 'Login',
|
||||
DESCRIPTION = 'Provides support for TOTP 2FA';
|
||||
|
||||
|
|
@ -21,6 +21,7 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
$this->addJs('js/TwoFactorAuthSettings.js');
|
||||
|
||||
$this->addHook('login.success', 'DoLogin');
|
||||
$this->addHook('filter.app-data', 'FilterAppData');
|
||||
|
||||
$this->addJsonHook('GetTwoFactorInfo', 'DoGetTwoFactorInfo');
|
||||
$this->addJsonHook('CreateTwoFactorSecret', 'DoCreateTwoFactorSecret');
|
||||
|
|
@ -33,6 +34,23 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
$this->addTemplate('templates/PopupsTwoFactorAuthTest.html');
|
||||
}
|
||||
|
||||
public function configMapping() : array
|
||||
{
|
||||
return [
|
||||
\RainLoop\Plugins\Property::NewInstance("force_two_factor_auth")
|
||||
// ->SetLabel('PLUGIN_TWO_FACTOR/LABEL_FORCE')
|
||||
->SetLabel('Enforce 2-Step Verification')
|
||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL),
|
||||
];
|
||||
}
|
||||
|
||||
public function FilterAppData($bAdmin, &$aResult)
|
||||
{
|
||||
if (!$bAdmin && \is_array($aResult)/* && isset($aResult['Auth']) && !$aResult['Auth']*/) {
|
||||
$aResult['RequireTwoFactor'] = $this->Config()->Get('plugin', 'force_two_factor_auth', false);
|
||||
}
|
||||
}
|
||||
|
||||
public function DoLogin(MainAccount $oAccount)
|
||||
{
|
||||
if ($this->TwoFactorAuthProvider($oAccount)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue