diff --git a/datamodels/2.x/itop-oauth-client/datamodel.itop-oauth-client.xml b/datamodels/2.x/itop-oauth-client/datamodel.itop-oauth-client.xml index 56bab8392..b934aba00 100644 --- a/datamodels/2.x/itop-oauth-client/datamodel.itop-oauth-client.xml +++ b/datamodels/2.x/itop-oauth-client/datamodel.itop-oauth-client.xml @@ -230,6 +230,7 @@ HTML $this->Set('refresh_token', $oAccessToken->getRefreshToken()); } $this->Set('status', 'active'); + $this->AllowWrite(); $this->DBUpdate(); } ]]> diff --git a/datamodels/2.x/itop-oauth-client/src/Controller/AjaxOauthClientController.php b/datamodels/2.x/itop-oauth-client/src/Controller/AjaxOauthClientController.php index a786290d4..723fc189d 100644 --- a/datamodels/2.x/itop-oauth-client/src/Controller/AjaxOauthClientController.php +++ b/datamodels/2.x/itop-oauth-client/src/Controller/AjaxOauthClientController.php @@ -11,6 +11,7 @@ use Combodo\iTop\Application\TwigBase\Controller\Controller; use Combodo\iTop\Core\Authentication\Client\OAuth\OAuthClientProviderFactory; use Dict; use IssueLog; +use League\OAuth2\Client\Provider\Exception\IdentityProviderException; use MetaModel; use utils; use WebPage; @@ -65,13 +66,15 @@ class AjaxOauthClientController extends Controller } if (isset($aQuery['code'])) { $sCode = $aQuery['code']; - $oAccessToken = OAuthClientProviderFactory::GetAccessTokenFromCode($oOAuthClient, $sCode); - - $oOAuthClient->SetAccessToken($oAccessToken); - - - - $aResult['status'] = 'success'; + try { + $oAccessToken = OAuthClientProviderFactory::GetAccessTokenFromCode($oOAuthClient, $sCode); + $oOAuthClient->SetAccessToken($oAccessToken); + $aResult['status'] = 'success'; + } + catch (IdentityProviderException $e) { + $aResult['status'] = 'error'; + $aResult['error_description'] = $e->getMessage(); + } } } else { $aResult['status'] = 'error'; diff --git a/setup/backup.class.inc.php b/setup/backup.class.inc.php index 9b38db6b8..0a5dc7c98 100644 --- a/setup/backup.class.inc.php +++ b/setup/backup.class.inc.php @@ -358,6 +358,7 @@ class DBBackup $sPortOption = self::GetMysqliCliSingleOption('port', $this->iDBPort); $sTlsOptions = self::GetMysqlCliTlsOptions($this->oConfig); + $sProtocolOption = self::GetMysqlCliTransportOption($this->sDBHost); $sMysqlVersion = CMDBSource::GetDBVersion(); $bIsMysqlSupportUtf8mb4 = (version_compare($sMysqlVersion, self::MYSQL_VERSION_WITH_UTF8MB4_IN_PROGRAMS) === -1); @@ -378,8 +379,8 @@ EOF; // Note: opt implicitely sets lock-tables... which cancels the benefit of single-transaction! // skip-lock-tables compensates and allows for writes during a backup - $sCommand = "$sMySQLDump --defaults-extra-file=\"$sMySQLDumpCnfFile\" --opt --skip-lock-tables --default-character-set=".$sMysqldumpCharset." --add-drop-database --single-transaction --host=$sHost $sPortOption --user=$sUser $sTlsOptions --result-file=$sTmpFileName $sDBName $sTables 2>&1"; - $sCommandDisplay = "$sMySQLDump --defaults-extra-file=\"$sMySQLDumpCnfFile\" --opt --skip-lock-tables --default-character-set=".$sMysqldumpCharset." --add-drop-database --single-transaction --host=$sHost $sPortOption --user=xxxxx $sTlsOptions --result-file=$sTmpFileName $sDBName $sTables"; + $sCommand = "$sMySQLDump --defaults-extra-file=\"$sMySQLDumpCnfFile\" --opt --skip-lock-tables --default-character-set=".$sMysqldumpCharset." --add-drop-database --single-transaction --host=$sHost $sPortOption $sProtocolOption --user=$sUser $sTlsOptions --result-file=$sTmpFileName $sDBName $sTables 2>&1"; + $sCommandDisplay = "$sMySQLDump --defaults-extra-file=\"$sMySQLDumpCnfFile\" --opt --skip-lock-tables --default-character-set=".$sMysqldumpCharset." --add-drop-database --single-transaction --host=$sHost $sPortOption $sProtocolOption --user=xxxxx $sTlsOptions --result-file=$sTmpFileName $sDBName $sTables"; // Now run the command for real $this->LogInfo("backup: generate data file with command: $sCommandDisplay"); @@ -576,6 +577,24 @@ EOF; return ' --'.$sCliArgName.'='.self::EscapeShellArg($sData); } + /** + * @param string $sHost + * + * @return string . + + * @since 2.7.9 3.0.4 3.1.1 N°6123 + */ + public static function GetMysqlCliTransportOption(string $sHost) + { + $sTransportOptions = ''; + + if($sHost === 'localhost'){ + $sTransportOptions = '--protocol=tcp'; + } + + return $sTransportOptions; + } + /** * @return string the command to launch mysqldump (without its params) */ diff --git a/sources/Core/Authentication/Client/OAuth/OAuthClientProviderFactory.php b/sources/Core/Authentication/Client/OAuth/OAuthClientProviderFactory.php index 66230eb3e..77006d436 100644 --- a/sources/Core/Authentication/Client/OAuth/OAuthClientProviderFactory.php +++ b/sources/Core/Authentication/Client/OAuth/OAuthClientProviderFactory.php @@ -74,6 +74,7 @@ class OAuthClientProviderFactory * @return AccessTokenInterface * @throws \ArchivedObjectException * @throws \CoreException + * @throws \League\OAuth2\Client\Provider\Exception\IdentityProviderException */ public static function GetAccessTokenFromCode(OAuthClient $oOAuthClient, $sCode) { @@ -109,7 +110,7 @@ class OAuthClientProviderFactory /** * @param \DBObject $oOAuthClient * - * @return mixed + * @return OAuthClientProviderAbstract * @throws \ArchivedObjectException * @throws \CoreException */