Merge branch 'support/3.0' into develop

# Conflicts:
#	sources/Core/Email/EmailSwiftMailer.php

Email by SMTP with self-signed certificate ported from EmailSwiftMailer to EmailLaminas
This commit is contained in:
Eric Espie
2022-11-30 14:35:13 +01:00
3 changed files with 39 additions and 39 deletions

View File

@@ -592,6 +592,22 @@ class Config
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'email_transport_smtp.allow_self_signed' => array(
'type' => 'bool',
'description' => 'Allow self signed peer certificates',
'default' => false,
'value' => false,
'source_of_value' => '',
'show_in_conf_sample' => false,
),
'email_transport_smtp.verify_peer' => array(
'type' => 'bool',
'description' => 'Verify peer certificate',
'default' => false,
'value' => false,
'source_of_value' => '',
'show_in_conf_sample' => false,
),
'email_css' => [
'type' => 'string',
'description' => 'CSS that will override the standard stylesheet used for the notifications',

View File

@@ -67,12 +67,12 @@
<default_value/>
<is_null_allowed>true</is_null_allowed>
</field>
<field id="client_id" xsi:type="AttributeText">
<field id="client_id" xsi:type="AttributeString">
<sql>client_id</sql>
<default_value/>
<is_null_allowed>false</is_null_allowed>
</field>
<field id="client_secret" xsi:type="AttributeText">
<field id="client_secret" xsi:type="AttributePassword">
<sql>client_secret</sql>
<default_value/>
<is_null_allowed>false</is_null_allowed>
@@ -321,7 +321,6 @@ HTML
<attributes>
<attribute id="provider"/>
<attribute id="client_id"/>
<attribute id="client_secret"/>
</attributes>
<is_blocking>true</is_blocking>
</rule>
@@ -481,21 +480,6 @@ HTML
$this->Set('scope', 'SMTP, IMAP');
parent::PrefillCreationForm($aContextParam);
}
]]></code>
</method>
<method id="OnUpdate">
<static>false</static>
<access>protected</access>
<type>Overload-DBObject</type>
<code><![CDATA[
protected function OnUpdate()
{
$aChanges = $this->ListChanges();
if (array_key_exists('client_id', $aChanges) || array_key_exists('client_secret', $aChanges) || array_key_exists('redirect_url', $aChanges)) {
$sMessage = Dict::S('itop-oauth-client:Message:RegenerateToken');
self::SetSessionMessage(get_class($this), $this->GetKey(), 'RegenerateToken', $sMessage, 'info', 1);
}
}
]]></code>
</method>
@@ -544,6 +528,12 @@ HTML
$this->Set('used_scope', 'advanced');
$this->Set('scope', '');
}
$aChanges = $this->ListChanges();
if (array_key_exists('client_id', $aChanges) || array_key_exists('client_secret', $aChanges) || array_key_exists('redirect_url', $aChanges)) {
$sMessage = Dict::S('itop-oauth-client:Message:RegenerateToken');
self::SetSessionMessage(get_class($this), $this->GetKey(), 'RegenerateToken', $sMessage, 'info', 1);
$this->Set('status', 'inactive');
}
}
]]></code>
</method>
@@ -645,7 +635,6 @@ HTML
<attributes>
<attribute id="provider"/>
<attribute id="client_id"/>
<attribute id="client_secret"/>
</attributes>
<is_blocking>true</is_blocking>
</rule>
@@ -855,6 +844,12 @@ HTML
$this->Set('used_scope', 'advanced');
$this->Set('scope', '');
}
$aChanges = $this->ListChanges();
if (array_key_exists('client_id', $aChanges) || array_key_exists('client_secret', $aChanges) || array_key_exists('redirect_url', $aChanges)) {
$sMessage = Dict::S('itop-oauth-client:Message:RegenerateToken');
self::SetSessionMessage(get_class($this), $this->GetKey(), 'RegenerateToken', $sMessage, 'info', 1);
$this->Set('status', 'inactive');
}
}
]]></code>
</method>
@@ -925,21 +920,6 @@ HTML
}
}
return implode(' ', $aRawScopes);
}
]]></code>
</method>
<method id="OnUpdate">
<static>false</static>
<access>protected</access>
<type>Overload-DBObject</type>
<code><![CDATA[
protected function OnUpdate()
{
$aChanges = $this->ListChanges();
if (array_key_exists('client_id', $aChanges) || array_key_exists('client_secret', $aChanges) || array_key_exists('redirect_url', $aChanges)) {
$sMessage = Dict::S('itop-oauth-client:Message:RegenerateToken');
self::SetSessionMessage(get_class($this), $this->GetKey(), 'RegenerateToken', $sMessage, 'info', 1);
}
}
]]></code>
</method>

View File

@@ -170,6 +170,8 @@ class EMailLaminas extends Email
$sEncryption = self::$m_oConfig->Get('email_transport_smtp.encryption');
$sUserName = self::$m_oConfig->Get('email_transport_smtp.username');
$sPassword = self::$m_oConfig->Get('email_transport_smtp.password');
$bAllowSelfSigned = static::$m_oConfig->Get('email_transport_smtp.allow_self_signed');
$bVerifyPeer = static::$m_oConfig->Get('email_transport_smtp.verify_peer');
$oTransport = new Smtp();
$aOptions = [
@@ -179,6 +181,8 @@ class EMailLaminas extends Email
'connection_config' => [
'ssl' => $sEncryption,
],
'allow_self_signed' => $bAllowSelfSigned,
'verify_peer' => $bVerifyPeer,
];
if (strlen($sUserName) > 0) {
$aOptions['connection_config']['username'] = $sUserName;