mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 10:09:20 +03:00
Added "Enforce 2-Step verification" setting
This commit is contained in:
parent
b7709c8117
commit
acb013fbb5
47 changed files with 1271 additions and 908 deletions
|
|
@ -1306,6 +1306,7 @@ class Actions
|
|||
'RegistrationLinkUrl' => \trim($oConfig->Get('login', 'registration_link_url', '')),
|
||||
'ContactsIsAllowed' => false,
|
||||
'ChangePasswordIsAllowed' => false,
|
||||
'RequireTwoFactor' => false,
|
||||
'JsHash' => \md5(\RainLoop\Utils::GetConnectionToken()),
|
||||
'UseImapThread' => (bool) $oConfig->Get('labs', 'use_imap_thread', false),
|
||||
'UseImapSubscribe' => (bool) $oConfig->Get('labs', 'use_imap_list_subscribe', true),
|
||||
|
|
@ -1479,6 +1480,20 @@ class Actions
|
|||
}
|
||||
|
||||
$aResult['Capa'] = $this->Capa(false, $oAccount);
|
||||
|
||||
if ($aResult['Auth'] && !$aResult['RequireTwoFactor'])
|
||||
{
|
||||
if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::TWO_FACTOR, $oAccount) &&
|
||||
$this->GetCapa(false, \RainLoop\Enumerations\Capa::TWO_FACTOR_FORCE, $oAccount) &&
|
||||
$this->TwoFactorAuthProvider()->IsActive())
|
||||
{
|
||||
$aData = $this->getTwoFactorInfo($oAccount, true);
|
||||
|
||||
$aResult['RequireTwoFactor'] = !$aData ||
|
||||
!isset($aData['User'], $aData['IsSet'], $aData['Enable']) ||
|
||||
!($aData['IsSet'] && $aData['Enable']);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3111,6 +3126,9 @@ class Actions
|
|||
case \RainLoop\Enumerations\Capa::TWO_FACTOR:
|
||||
$this->setConfigFromParams($oConfig, $sParamName, 'security', 'allow_two_factor_auth', 'bool');
|
||||
break;
|
||||
case \RainLoop\Enumerations\Capa::TWO_FACTOR_FORCE:
|
||||
$this->setConfigFromParams($oConfig, $sParamName, 'security', 'force_two_factor_auth', 'bool');
|
||||
break;
|
||||
case \RainLoop\Enumerations\Capa::GRAVATAR:
|
||||
$this->setConfigFromParams($oConfig, $sParamName, 'labs', 'allow_gravatar', 'bool');
|
||||
break;
|
||||
|
|
@ -3216,6 +3234,7 @@ class Actions
|
|||
$this->setCapaFromParams($oConfig, 'CapaAdditionalAccounts', \RainLoop\Enumerations\Capa::ADDITIONAL_ACCOUNTS);
|
||||
$this->setCapaFromParams($oConfig, 'CapaTemplates', \RainLoop\Enumerations\Capa::TEMPLATES);
|
||||
$this->setCapaFromParams($oConfig, 'CapaTwoFactorAuth', \RainLoop\Enumerations\Capa::TWO_FACTOR);
|
||||
$this->setCapaFromParams($oConfig, 'CapaTwoFactorAuthForce', \RainLoop\Enumerations\Capa::TWO_FACTOR_FORCE);
|
||||
$this->setCapaFromParams($oConfig, 'CapaOpenPGP', \RainLoop\Enumerations\Capa::OPEN_PGP);
|
||||
$this->setCapaFromParams($oConfig, 'CapaGravatar', \RainLoop\Enumerations\Capa::GRAVATAR);
|
||||
$this->setCapaFromParams($oConfig, 'CapaThemes', \RainLoop\Enumerations\Capa::THEMES);
|
||||
|
|
@ -7772,6 +7791,12 @@ class Actions
|
|||
($bAdmin || ($oAccount && !$oAccount->IsAdditionalAccount())))
|
||||
{
|
||||
$aResult[] = \RainLoop\Enumerations\Capa::TWO_FACTOR;
|
||||
|
||||
if ($oConfig->Get('security', 'force_two_factor_auth', false) &&
|
||||
($bAdmin || ($oAccount && !$oAccount->IsAdditionalAccount())))
|
||||
{
|
||||
$aResult[] = \RainLoop\Enumerations\Capa::TWO_FACTOR_FORCE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($oConfig->Get('labs', 'allow_gravatar', false))
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
'admin_password' => array('12345'),
|
||||
'allow_admin_panel' => array(true, 'Access settings'),
|
||||
'allow_two_factor_auth' => array(false),
|
||||
'force_two_factor_auth' => array(false),
|
||||
'allow_universal_login' => array(false),
|
||||
'admin_panel_host' => array(''),
|
||||
'core_install_access_domain' => array('')
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ class Capa
|
|||
{
|
||||
const PREM = 'PREM';
|
||||
const TWO_FACTOR = 'TWO_FACTOR';
|
||||
const TWO_FACTOR_FORCE = 'TWO_FACTOR_FORCE';
|
||||
const OPEN_PGP = 'OPEN_PGP';
|
||||
const PREFETCH = 'PREFETCH';
|
||||
const GRAVATAR = 'GRAVATAR';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue