Validate FCM service account JSON content

This commit is contained in:
Kijin Sung 2024-04-24 00:27:04 +09:00
parent c7f96ad75b
commit 296f37f5f5
3 changed files with 12 additions and 0 deletions

View file

@ -183,6 +183,16 @@ class Notification extends Base
}
$push_config[$driver_name][$conf_name] = $conf_value;
// Validate the FCM service account.
if ($conf_name === 'service_account' && $conf_value !== null)
{
$decoded_value = @json_decode($conf_value, true);
if (!$decoded_value || !isset($decoded_value['project_id']) || !isset($decoded_value['private_key']))
{
throw new Exception('msg_advanced_mailer_invalid_fcm_json');
}
}
// Save certificates in a separate file and only store the filename in config.php.
if ($conf_name === 'certificate' || $conf_name === 'service_account')
{