mirror of
https://github.com/itflow-org/itflow
synced 2026-12-02 00:59:03 +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:
@@ -67,17 +67,18 @@ $config_enable_cron = intval($row['config_enable_cron']);
|
||||
// SMTP baseline
|
||||
$config_smtp_host = $row['config_smtp_host'];
|
||||
$config_smtp_username = $row['config_smtp_username'];
|
||||
$config_smtp_password = $row['config_smtp_password'];
|
||||
// Encrypted in the database (functions/mail_secret.php)
|
||||
$config_smtp_password = mailSecretOpen($row['config_smtp_password']);
|
||||
$config_smtp_port = intval($row['config_smtp_port']);
|
||||
$config_smtp_encryption = $row['config_smtp_encryption'];
|
||||
|
||||
// SMTP provider + shared OAuth fields
|
||||
$config_smtp_provider = $row['config_smtp_provider']; // 'standard_smtp' | 'google_oauth' | 'microsoft_oauth'
|
||||
$config_mail_oauth_client_id = $row['config_mail_oauth_client_id'] ?? '';
|
||||
$config_mail_oauth_client_secret = $row['config_mail_oauth_client_secret'] ?? '';
|
||||
$config_mail_oauth_client_secret = mailSecretOpen($row['config_mail_oauth_client_secret'] ?? '');
|
||||
$config_mail_oauth_tenant_id = $row['config_mail_oauth_tenant_id'] ?? '';
|
||||
$config_mail_oauth_refresh_token = $row['config_mail_oauth_refresh_token'] ?? '';
|
||||
$config_mail_oauth_access_token = $row['config_mail_oauth_access_token'] ?? '';
|
||||
$config_mail_oauth_refresh_token = mailSecretOpen($row['config_mail_oauth_refresh_token'] ?? '');
|
||||
$config_mail_oauth_access_token = mailSecretOpen($row['config_mail_oauth_access_token'] ?? '');
|
||||
$config_mail_oauth_access_token_expires_at = $row['config_mail_oauth_access_token_expires_at'] ?? '';
|
||||
|
||||
// Switched off isn't an error - Maintenance > Cron shows why it stopped
|
||||
@@ -126,16 +127,12 @@ function tokenIsExpired(?string $expires_at): bool {
|
||||
function persistMailOauthTokens(string $access_token, string $expires_at, ?string $refresh_token = null): void {
|
||||
global $mysqli;
|
||||
|
||||
$access_token_esc = mysqli_real_escape_string($mysqli, $access_token);
|
||||
$expires_at_esc = mysqli_real_escape_string($mysqli, $expires_at);
|
||||
|
||||
$refresh_sql = '';
|
||||
if (!empty($refresh_token)) {
|
||||
$refresh_token_esc = mysqli_real_escape_string($mysqli, $refresh_token);
|
||||
$refresh_sql = ", config_mail_oauth_refresh_token = '{$refresh_token_esc}'";
|
||||
}
|
||||
// Sealed (functions/mail_secret.php)
|
||||
$refresh_sql = !empty($refresh_token) ? ', ' . mailSecretSql('config_mail_oauth_refresh_token', $refresh_token) : '';
|
||||
|
||||
mysqli_query($mysqli, "UPDATE settings SET config_mail_oauth_access_token = '{$access_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', $access_token) . ", config_mail_oauth_access_token_expires_at = '{$expires_at_esc}'{$refresh_sql} WHERE company_id = 1");
|
||||
|
||||
// This run's copy too, so the next email uses the new token rather than fetching another
|
||||
$GLOBALS['config_mail_oauth_access_token'] = $access_token;
|
||||
|
||||
Reference in New Issue
Block a user