N°3169 - Add feature to connect Gsuite mail box with OAuth

N°2504 - Add feature to connect Office mail box with OAuth2 for Microsoft Graph
N°5102 - Allow to send emails (eg. notifications) using GSuite SMTP and OAuth
 * 2.7 migration (wip)
This commit is contained in:
Eric Espie
2022-05-13 12:07:27 +02:00
parent 6b80bbeaa2
commit 8c217fdac9
7 changed files with 32 additions and 80 deletions

View File

@@ -151,6 +151,7 @@ return array(
'Combodo\\iTop\\Composer\\iTopComposer' => $baseDir . '/sources/Composer/iTopComposer.php',
'Combodo\\iTop\\Controller\\AjaxRenderController' => $baseDir . '/sources/Controller/AjaxRenderController.php',
'Combodo\\iTop\\Controller\\OAuth\\OAuthAjaxController' => $baseDir . '/sources/Controller/OAuth/OAuthAjaxController.php',
'Combodo\\iTop\\Controller\\OAuth\\OAuthLandingController' => $baseDir . '/sources/Controller/OAuth/OAuthLandingController.php',
'Combodo\\iTop\\Controller\\OAuth\\OAuthWizardController' => $baseDir . '/sources/Controller/OAuth/OAuthWizardController.php',
'Combodo\\iTop\\Core\\Authentication\\Client\\OAuth\\IOAuthClientProvider' => $baseDir . '/sources/Core/Authentication/Client/OAuth/IOAuthClientProvider.php',
'Combodo\\iTop\\Core\\Authentication\\Client\\OAuth\\IOAuthClientResultDisplay' => $baseDir . '/sources/Core/Authentication/Client/OAuth/IOAuthClientResultDisplay.php',

View File

@@ -519,6 +519,7 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
'Combodo\\iTop\\Composer\\iTopComposer' => __DIR__ . '/../..' . '/sources/Composer/iTopComposer.php',
'Combodo\\iTop\\Controller\\AjaxRenderController' => __DIR__ . '/../..' . '/sources/Controller/AjaxRenderController.php',
'Combodo\\iTop\\Controller\\OAuth\\OAuthAjaxController' => __DIR__ . '/../..' . '/sources/Controller/OAuth/OAuthAjaxController.php',
'Combodo\\iTop\\Controller\\OAuth\\OAuthLandingController' => __DIR__ . '/../..' . '/sources/Controller/OAuth/OAuthLandingController.php',
'Combodo\\iTop\\Controller\\OAuth\\OAuthWizardController' => __DIR__ . '/../..' . '/sources/Controller/OAuth/OAuthWizardController.php',
'Combodo\\iTop\\Core\\Authentication\\Client\\OAuth\\IOAuthClientProvider' => __DIR__ . '/../..' . '/sources/Core/Authentication/Client/OAuth/IOAuthClientProvider.php',
'Combodo\\iTop\\Core\\Authentication\\Client\\OAuth\\IOAuthClientResultDisplay' => __DIR__ . '/../..' . '/sources/Core/Authentication/Client/OAuth/IOAuthClientResultDisplay.php',

View File

@@ -11,64 +11,3 @@ $oUpdateController = new OAuthAjaxController($sTemplates, 'core');
$oUpdateController->AllowOnlyAdmin();
$oUpdateController->SetDefaultOperation('Default');
$oUpdateController->HandleOperation();
//require_once(APPROOT.'application/utils.inc.php');
//require_once(APPROOT.'/application/application.inc.php');
//
//require_once(APPROOT.'/application/loginwebpage.class.inc.php');
//
//$oPage = new JsonPage();
//$oPage->SetOutputDataOnly(true);
//$aResult = ['status' => 'success', 'data' => []];
//try {
// $operation = utils::ReadParam('operation', '');
//
// switch ($operation) {
// case 'get_authorization_url':
// $sProvider = utils::ReadParam('provider', '', false, 'raw');
// $sClientId = utils::ReadParam('client_id', '', false, 'raw');
// $sClientSecret = utils::ReadParam('client_secret', '', false, 'raw');
// $sScope = utils::ReadParam('scope', '', false, 'raw');
// $sAdditional = utils::ReadParam('additional', '', false, 'raw');
// $aAdditional = [];
// parse_str($sAdditional, $aAdditional);
// $sAuthorizationUrl = OAuthClientProviderFactory::getVendorProviderForAccessUrl($sProvider, $sClientId, $sClientSecret, $sScope, $aAdditional);
// $aResult['data']['authorization_url'] = $sAuthorizationUrl;
// break;
// case 'get_display_authentication_results':
// $sProvider = utils::ReadParam('provider', '', false, 'raw');
// $sRedirectUrl = utils::ReadParam('redirect_url', '', false, 'raw');
// $sClientId = utils::ReadParam('client_id', '', false, 'raw');
// $sClientSecret = utils::ReadParam('client_secret', '', false, 'raw');
// $sScope = utils::ReadParam('scope', '', false, 'raw');
// $sAdditional = utils::ReadParam('additional', '', false, 'raw');
//
// $sRedirectUrlQuery = parse_url($sRedirectUrl)['query'];
// $aOAuthResultDisplayClasses = utils::GetClassesForInterface('Combodo\iTop\Core\Authentication\Client\OAuth\IOAuthClientResultDisplay', '', array('[\\\\/]lib[\\\\/]', '[\\\\/]node_modules[\\\\/]', '[\\\\/]test[\\\\/]'));
// $aAdditional = [];
// parse_str($sAdditional, $aAdditional);
//
// $sProviderClass = "\Combodo\iTop\Core\Authentication\Client\OAuth\OAuthClientProvider".$sProvider;
// $sRedirectUrl = OAuthClientProviderAbstract::GetRedirectUri();
//
// $aQuery = [];
// parse_str($sRedirectUrlQuery, $aQuery);
// $sCode = $aQuery['code'];
// $oProvider = OAuthClientProviderFactory::getVendorProvider($sProvider, $sClientId, $sClientSecret, $sScope, $aAdditional);
// $oAccessToken = OAuthClientProviderFactory::getAccessTokenFromCode($oProvider, $sCode);
//
// foreach($aOAuthResultDisplayClasses as $sOAuthClass) {
// $aResult['data'][] = $sOAuthClass::GetResultDisplayScript($sClientId, $sClientSecret, $sProvider, $oAccessToken);
// }
// }
//}
//catch(Exception $e){
// $aResult['status'] = 'error';
// IssueLog::Error($e->getMessage());
//}
//$oPage->SetData($aResult);
//$oPage->output();

View File

@@ -1,26 +1,14 @@
<?php
use Combodo\iTop\Application\UI\Base\Layout\PageContent\PageContent;
use Combodo\iTop\Controller\OAuth\OAuthLandingController;
require_once('../approot.inc.php');
require_once(APPROOT.'/application/application.inc.php');
require_once(APPROOT.'/application/startup.inc.php');
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
$sTemplates = APPROOT.'templates/pages/backoffice/oauth';
$oLayout = new PageContent();
$oLayout->AddCSSClass('ibo-oauth-wizard--side-pane');
$oPage = new WebPage(Dict::S('UI:Schema:Title'));
$sJS = <<<JS
window.addEventListener("message", function (event){
event.source.postMessage(window.location.href, event.origin);
window.close();
}, false);
JS;
$oPage->add_script($sJS);
$oPage->output();
$oUpdateController = new OAuthLandingController($sTemplates, 'core');
$oUpdateController->AllowOnlyAdmin();
$oUpdateController->SetDefaultOperation('Landing');
$oUpdateController->HandleOperation();

View File

@@ -0,0 +1,13 @@
<?php
namespace Combodo\iTop\Controller\OAuth;
use Combodo\iTop\Application\TwigBase\Controller\Controller;
class OAuthLandingController extends Controller
{
public function OperationLanding()
{
$this->DisplayPage([]);
}
}

View File

@@ -0,0 +1,3 @@
{# @copyright Copyright (C) 2010-2022 Combodo SARL #}
{# @license http://opensource.org/licenses/AGPL-3.0 #}

View File

@@ -0,0 +1,7 @@
{# @copyright Copyright (C) 2010-2022 Combodo SARL #}
{# @license http://opensource.org/licenses/AGPL-3.0 #}
window.addEventListener("message", function (event){
event.source.postMessage(window.location.href, event.origin);
window.close();
}, false);