mirror of
https://github.com/itflow-org/itflow
synced 2026-12-02 09:09:01 +00:00
Mail review stage 7a: mail passwords, the OAuth client secret and the mail tokens are stored encrypted with a key from config.php's backup key, kept as typed only when there is no key, with a warning in Admin > Settings > Mail when they can't be read (database 4.3.1); pictures from other sites in client email are held back on a ticket, its quick look and its work order until Show pictures is clicked; the sign-in page no longer loads the mail server's password; 26.12.3 changelog
This commit is contained in:
@@ -136,7 +136,7 @@ if (isset($_POST['edit_mail_oauth_settings']) || isset($_POST['oauth_connect_mic
|
||||
}
|
||||
|
||||
$config_mail_oauth_client_id = $after['config_mail_oauth_client_id'];
|
||||
$config_mail_oauth_client_secret = $after['config_mail_oauth_client_secret'];
|
||||
$config_mail_oauth_client_secret = mailSecretOpen($after['config_mail_oauth_client_secret']);
|
||||
$config_mail_oauth_tenant_id = $after['config_mail_oauth_tenant_id'];
|
||||
if ($config_mail_oauth_client_id === '' || $config_mail_oauth_client_secret === '' || $config_mail_oauth_tenant_id === '') {
|
||||
flashAlert("The app's client ID, secret and tenant ID first - then connect.", 'error');
|
||||
@@ -402,16 +402,12 @@ if (isset($_POST['test_email_imap'])) {
|
||||
$expires_at = date('Y-m-d H:i:s', time() + intval($json['expires_in'] ?? 3600));
|
||||
$refresh_token_to_save = $json['refresh_token'] ?? null;
|
||||
|
||||
$token_esc = mysqli_real_escape_string($mysqli, $password);
|
||||
$expires_at_esc = mysqli_real_escape_string($mysqli, $expires_at);
|
||||
|
||||
$refresh_sql = '';
|
||||
if (!empty($refresh_token_to_save)) {
|
||||
$refresh_token_esc = mysqli_real_escape_string($mysqli, $refresh_token_to_save);
|
||||
$refresh_sql = ", config_mail_oauth_refresh_token = '{$refresh_token_esc}'";
|
||||
}
|
||||
// Sealed (functions/mail_secret.php)
|
||||
$refresh_sql = !empty($refresh_token_to_save) ? ', ' . mailSecretSql('config_mail_oauth_refresh_token', $refresh_token_to_save) : '';
|
||||
|
||||
mysqli_query($mysqli, "UPDATE settings SET config_mail_oauth_access_token = '{$token_esc}', config_mail_oauth_access_token_expires_at = '{$expires_at_esc}'{$refresh_sql} WHERE company_id = 1");
|
||||
mysqli_query($mysqli, "UPDATE settings SET " . mailSecretSql('config_mail_oauth_access_token', $password) . ", config_mail_oauth_access_token_expires_at = '{$expires_at_esc}'{$refresh_sql} WHERE company_id = 1");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -513,20 +509,16 @@ if (isset($_POST['test_oauth_token_refresh'])) {
|
||||
redirect($mail_tab_redirect);
|
||||
}
|
||||
|
||||
$new_access_token = escapeSql($json['access_token']);
|
||||
$new_access_token = (string) $json['access_token'];
|
||||
$new_expires_at = date('Y-m-d H:i:s', time() + intval($json['expires_in'] ?? 3600));
|
||||
$new_refresh_token = !empty($json['refresh_token']) ? escapeSql($json['refresh_token']) : '';
|
||||
$new_refresh_token = !empty($json['refresh_token']) ? (string) $json['refresh_token'] : '';
|
||||
|
||||
$new_access_token_esc = mysqli_real_escape_string($mysqli, $new_access_token);
|
||||
$new_expires_at_esc = mysqli_real_escape_string($mysqli, $new_expires_at);
|
||||
|
||||
$refresh_sql = '';
|
||||
if (!empty($new_refresh_token)) {
|
||||
$new_refresh_token_esc = mysqli_real_escape_string($mysqli, $new_refresh_token);
|
||||
$refresh_sql = ", config_mail_oauth_refresh_token = '$new_refresh_token_esc'";
|
||||
}
|
||||
// Sealed (functions/mail_secret.php) - and as Microsoft or Google sent them: escapeSql() then mysqli_real_escape_string() escaped them twice
|
||||
$refresh_sql = $new_refresh_token !== '' ? ', ' . mailSecretSql('config_mail_oauth_refresh_token', $new_refresh_token) : '';
|
||||
|
||||
mysqli_query($mysqli, "UPDATE settings SET config_mail_oauth_access_token = '$new_access_token_esc', config_mail_oauth_access_token_expires_at = '$new_expires_at_esc'$refresh_sql WHERE company_id = 1");
|
||||
mysqli_query($mysqli, "UPDATE settings SET " . mailSecretSql('config_mail_oauth_access_token', $new_access_token) . ", config_mail_oauth_access_token_expires_at = '$new_expires_at_esc'$refresh_sql WHERE company_id = 1");
|
||||
|
||||
$provider_label = $provider === 'microsoft_oauth' ? 'Microsoft 365' : 'Google Workspace';
|
||||
logAudit("Settings", "Edit", "$session_name tested OAuth token refresh for $provider_label mail settings");
|
||||
|
||||
Reference in New Issue
Block a user