From 74702c8d06072c83715d6a6807ee86ac890c5649 Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Tue, 22 Nov 2022 17:18:41 +0100 Subject: [PATCH 1/2] =?UTF-8?q?N=C2=B05430=20-=20OAuth=20authentication=20?= =?UTF-8?q?:=20customize=20redirect=20landing=20URL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datamodel.itop-oauth-client.xml | 40 +++++++++++++++---- .../en.dict.itop-oauth-client.php | 1 + .../fr.dict.itop-oauth-client.php | 1 + 3 files changed, 34 insertions(+), 8 deletions(-) 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 c39eb2f1d..3335ab29a 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 @@ -441,6 +441,21 @@ } ]]> + + false + protected + Overload-DBObject + 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); + } + } + ]]> + false public @@ -450,15 +465,13 @@ parent::DoCheckToWrite(); $aChanges = $this->ListChanges(); - if (array_key_exists('name', $aChanges) || array_key_exists('used_for_smtp', $aChanges)) - { + if (array_key_exists('name', $aChanges) || array_key_exists('used_for_smtp', $aChanges)) { $sNewName = $this->Get('name'); $sNewUseForSMTP = $this->Get('used_for_smtp'); if ($sNewUseForSMTP == 'yes') { $oSearch = DBObjectSearch::FromOQL_AllData("SELECT OAuthClientGoogle WHERE name = :newname AND used_for_smtp = :newuseforsmtp AND id != :id UNION SELECT OAuthClientAzure WHERE name = :newname AND used_for_smtp = :newuseforsmtp AND id != :id"); $oSet = new DBObjectSet($oSearch, array(), ['id' => $this->GetKey(), 'newname' => $sNewName, 'newuseforsmtp' => $sNewUseForSMTP]); - if ($oSet->Count() > 0) - { + if ($oSet->Count() > 0) { $this->m_aCheckIssues[] = Dict::Format('OAuthClient:Name/UseForSMTPMustBeUnique', $sNewName, $sNewUseForSMTP); } } @@ -500,7 +513,6 @@ { switch ($sAttCode) { case 'provider': - case 'redirect_url': case 'used_scope': return OPT_ATT_READONLY; } @@ -518,7 +530,6 @@ { switch ($sAttCode) { case 'provider': - case 'redirect_url': case 'used_scope': return OPT_ATT_READONLY; } @@ -800,7 +811,6 @@ { switch ($sAttCode) { case 'provider': - case 'redirect_url': case 'used_scope': return OPT_ATT_READONLY; } @@ -818,7 +828,6 @@ { switch ($sAttCode) { case 'provider': - case 'redirect_url': case 'used_scope': return OPT_ATT_READONLY; } @@ -863,6 +872,21 @@ } ]]> + + false + protected + Overload-DBObject + 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); + } + } + ]]> + diff --git a/datamodels/2.x/itop-oauth-client/en.dict.itop-oauth-client.php b/datamodels/2.x/itop-oauth-client/en.dict.itop-oauth-client.php index 5c3a66132..630eaea63 100644 --- a/datamodels/2.x/itop-oauth-client/en.dict.itop-oauth-client.php +++ b/datamodels/2.x/itop-oauth-client/en.dict.itop-oauth-client.php @@ -19,6 +19,7 @@ Dict::Add('EN US', 'English', 'English', [ 'itop-oauth-client:TestSMTP' => 'Email send test', 'itop-oauth-client:MissingOAuthClient' => 'Missing Oauth client for user name %1$s', 'itop-oauth-client:Message:MissingToken' => 'Generate access token before using this OAuth client', + 'itop-oauth-client:Message:RegenerateToken' => 'Regenerate access token to to take into account the changes', 'itop-oauth-client:Message:TokenCreated' => 'Access token created', 'itop-oauth-client:Message:TokenRecreated' => 'Access token regenerated', 'itop-oauth-client:Message:TokenError' => 'Access token not generated due to server error', diff --git a/datamodels/2.x/itop-oauth-client/fr.dict.itop-oauth-client.php b/datamodels/2.x/itop-oauth-client/fr.dict.itop-oauth-client.php index 339538d52..9797153e8 100644 --- a/datamodels/2.x/itop-oauth-client/fr.dict.itop-oauth-client.php +++ b/datamodels/2.x/itop-oauth-client/fr.dict.itop-oauth-client.php @@ -19,6 +19,7 @@ Dict::Add('FR FR', 'French', 'Français', [ 'itop-oauth-client:TestSMTP' => 'Tester l\'envoi de mail', 'itop-oauth-client:MissingOAuthClient' => 'Il n\'y a pas de client OAuth pour l\'utilisateur %1$s', 'itop-oauth-client:Message:MissingToken' => 'Générez le jeton d\'accès avant d\'utiliser ce client OAuth', + 'itop-oauth-client:Message:RegenerateToken' => 'Re-générez le jeton d\'accès prendre en compte les modifications', 'itop-oauth-client:Message:TokenCreated' => 'Le jeton d\'accès à été créé', 'itop-oauth-client:Message:TokenRecreated' => 'Le jeton d\'accès à été renouvelé', 'itop-oauth-client:Message:TokenError' => 'Le jeton d\'accès n\'a pas été généré à cause d`une erreur serveur', From d292a6b0c340330c11c3de163e8004ed16f0c451 Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Tue, 22 Nov 2022 17:24:41 +0100 Subject: [PATCH 2/2] =?UTF-8?q?N=C2=B05333=20-=20OAuth=20and=20iTop=20url?= =?UTF-8?q?=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2.x/itop-oauth-client/en.dict.itop-oauth-client.php | 6 +++++- .../2.x/itop-oauth-client/fr.dict.itop-oauth-client.php | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/datamodels/2.x/itop-oauth-client/en.dict.itop-oauth-client.php b/datamodels/2.x/itop-oauth-client/en.dict.itop-oauth-client.php index 630eaea63..b64e1c838 100644 --- a/datamodels/2.x/itop-oauth-client/en.dict.itop-oauth-client.php +++ b/datamodels/2.x/itop-oauth-client/en.dict.itop-oauth-client.php @@ -59,7 +59,11 @@ Dict::Add('EN US', 'English', 'English', [ 'Class:OAuthClient/Attribute:token_expiration' => 'Access token expiration', 'Class:OAuthClient/Attribute:token_expiration+' => '', 'Class:OAuthClient/Attribute:redirect_url' => 'Redirect url', - 'Class:OAuthClient/Attribute:redirect_url+' => 'This url must be copied in the OAuth2 configuration of the provider', + 'Class:OAuthClient/Attribute:redirect_url+' => << 'Mailbox list', 'Class:OAuthClient/Attribute:mailbox_list+' => '', ]); diff --git a/datamodels/2.x/itop-oauth-client/fr.dict.itop-oauth-client.php b/datamodels/2.x/itop-oauth-client/fr.dict.itop-oauth-client.php index 9797153e8..b747f91e0 100644 --- a/datamodels/2.x/itop-oauth-client/fr.dict.itop-oauth-client.php +++ b/datamodels/2.x/itop-oauth-client/fr.dict.itop-oauth-client.php @@ -59,7 +59,11 @@ Dict::Add('FR FR', 'French', 'Français', [ 'Class:OAuthClient/Attribute:token_expiration' => 'Date d\'expiration du jeton d\'accès', 'Class:OAuthClient/Attribute:token_expiration+' => '', 'Class:OAuthClient/Attribute:redirect_url' => 'URL de redirection', - 'Class:OAuthClient/Attribute:redirect_url+' => 'Cet URL doit être recopié dans la configuration OAuth2 de votre fournisseur', + 'Class:OAuthClient/Attribute:redirect_url+' => << 'Mailbox list', 'Class:OAuthClient/Attribute:mailbox_list+' => '', ]);