exclude oauth clients & app passwords from mailbox tfa
This commit is contained in:
parent
528f7da5ef
commit
be08742653
@ -807,7 +807,7 @@ function verify_hash($hash, $password) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function check_login($user, $pass, $app_passwd_data = false) {
|
function check_login($user, $pass, $app_passwd_data = false, $skip_tfa = false) {
|
||||||
global $pdo;
|
global $pdo;
|
||||||
global $redis;
|
global $redis;
|
||||||
global $imap_server;
|
global $imap_server;
|
||||||
@ -938,6 +938,8 @@ function check_login($user, $pass, $app_passwd_data = false) {
|
|||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
// verify password
|
// verify password
|
||||||
if (verify_hash($row['password'], $pass) !== false) {
|
if (verify_hash($row['password'], $pass) !== false) {
|
||||||
|
|
||||||
|
if ($app_passwd_data['eas'] !== true && $app_passwd_data['dav'] !== true && !$skip_tfa){
|
||||||
// check for tfa authenticators
|
// check for tfa authenticators
|
||||||
$authenticators = get_tfa($user);
|
$authenticators = get_tfa($user);
|
||||||
if (isset($authenticators['additional']) && is_array($authenticators['additional']) && count($authenticators['additional']) > 0) {
|
if (isset($authenticators['additional']) && is_array($authenticators['additional']) && count($authenticators['additional']) > 0) {
|
||||||
@ -951,6 +953,7 @@ function check_login($user, $pass, $app_passwd_data = false) {
|
|||||||
'msg' => array('logged_in_as', $user)
|
'msg' => array('logged_in_as', $user)
|
||||||
);
|
);
|
||||||
return "pending";
|
return "pending";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($app_passwd_data['eas'] === true || $app_passwd_data['dav'] === true) {
|
if ($app_passwd_data['eas'] === true || $app_passwd_data['dav'] === true) {
|
||||||
$service = ($app_passwd_data['eas'] === true) ? 'EAS' : 'DAV';
|
$service = ($app_passwd_data['eas'] === true) ? 'EAS' : 'DAV';
|
||||||
@ -961,12 +964,13 @@ function check_login($user, $pass, $app_passwd_data = false) {
|
|||||||
':username' => $user,
|
':username' => $user,
|
||||||
':remote_addr' => ($_SERVER['HTTP_X_REAL_IP'] ?? $_SERVER['REMOTE_ADDR'])
|
':remote_addr' => ($_SERVER['HTTP_X_REAL_IP'] ?? $_SERVER['REMOTE_ADDR'])
|
||||||
));
|
));
|
||||||
}
|
} elseif (!$skip_tfa) {
|
||||||
|
|
||||||
unset($_SESSION['ldelay']);
|
|
||||||
// Reactivate TFA if it was set to "deactivate TFA for next login"
|
// Reactivate TFA if it was set to "deactivate TFA for next login"
|
||||||
$stmt = $pdo->prepare("UPDATE `tfa` SET `active`='1' WHERE `username` = :user");
|
$stmt = $pdo->prepare("UPDATE `tfa` SET `active`='1' WHERE `username` = :user");
|
||||||
$stmt->execute(array(':user' => $user));
|
$stmt->execute(array(':user' => $user));
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($_SESSION['ldelay']);
|
||||||
return "user";
|
return "user";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ class mailcowPdo extends OAuth2\Storage\Pdo {
|
|||||||
$this->config['user_table'] = 'mailbox';
|
$this->config['user_table'] = 'mailbox';
|
||||||
}
|
}
|
||||||
public function checkUserCredentials($username, $password) {
|
public function checkUserCredentials($username, $password) {
|
||||||
if (check_login($username, $password) == 'user') {
|
if (check_login($username, $password, false, true) == 'user') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user