cmdbAbstractObject grant_by_profile,application true autoincrement priv_oauth_client id provider false name false true active inactive status inactive false description true client_id false client_secret false refresh_token true none refresh_token_expiration true none token true none token_expiration true none redirect_url _blank true MailInboxOAuth oauth_client_id 0 0 false public Overload-DBObject Get('status') == 'inactive') { $sLabel = Dict::S('itop-oauth-client:Message:MissingToken'); $sTitle = ''; $aTags['oauth-message'] = ['title' => $sTitle, 'css_classes' => 'ibo-object-details--tag--oauth-message', 'decoration_classes' => 'fas fa-exclamation-triangle', 'label' => $sLabel]; } elseif ($this->Get('used_for_smtp') == 'yes' && $oConfig->Get('email_transport_smtp.username') == $this->Get('name')) { $sLabel = Dict::S('itop-oauth-client:UsedForSMTP'); $sTestLabel = Dict::S('itop-oauth-client:TestSMTP'); $sTestURL = utils::GetAbsoluteUrlAppRoot().'setup/email.test.php'; $sLabel = Dict::S('itop-oauth-client:UsedForSMTP')." $sTestLabel"; $sTitle = ''; $aTags['oauth-message'] = ['title' => $sTitle, 'css_classes' => 'ibo-object-details--tag--oauth-message', 'decoration_classes' => 'fas fa-envelope', 'label' => $sLabel]; } } foreach ($aTags as $sIconId => $aIconData) { $aHeaderBlocks['subtitle'][static::HEADER_BLOCKS_SUBTITLE_TAG_PREFIX.$sIconId] = new Combodo\iTop\Application\UI\Base\Component\Html\Html(<<{$aIconData['label']} HTML ); } return $aHeaderBlocks; } ]]> false public Overload-DBObject false public Overload-DBObject false public Get('provider').'.com'; } ]]> false public false public Get('status') == 'active') { return new \League\OAuth2\Client\Token\AccessToken([ 'access_token' => $this->Get('token'), 'expires_in' => date_format(new DateTime($this->Get('token_expiration')), 'U') - time(), 'refresh_token' => $this->Get('refresh_token'), 'token_type' => 'Bearer', ]); } return null; } ]]> false public Set('token', $oAccessToken->getToken()); $this->Set('token_expiration', date(AttributeDateTime::GetSQLFormat(), $oAccessToken->getExpires())); if (!empty($oAccessToken->getRefreshToken())) { $this->Set('refresh_token', $oAccessToken->getRefreshToken()); } $this->Set('status', 'active'); $this->AllowWrite(); $this->DBUpdate(); } ]]>
1 2 3 5 6 7 8
1 3 1 2 1 2
OAuthClient grant_by_profile,application false autoincrement priv_oauth_client_azure id true true SMTP IMAP scope SMTP,IMAP true advanced_scope true true simple advanced used_scope simple false true yes no used_for_smtp no true tenant common false
10 10 10 20 30 40 50 60 70 80 90 20 10 10 20 30 40
10 10 10 10 10
false public Overload-DBObject Set('provider', 'Azure'); $this->Set('redirect_url', Combodo\iTop\Core\Authentication\Client\OAuth\OAuthClientProviderFactory::GetRedirectUri()); $this->Set('scope', 'SMTP, IMAP'); parent::PrefillCreationForm($aContextParam); } ]]> false public Overload-DBObject ListChanges(); 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) { $this->m_aCheckIssues[] = Dict::Format('OAuthClient:Name/UseForSMTPMustBeUnique', $sNewName, $sNewUseForSMTP); } } } } ]]> false public Overload-DBObject Get('provider'))) { $this->Set('provider', 'Azure'); } if (empty($this->Get('redirect_url'))) { $this->Set('redirect_url', Combodo\iTop\Core\Authentication\Client\OAuth\OAuthClientProviderFactory::GetRedirectUri()); } if (empty($this->Get('advanced_scope'))) { $this->Set('used_scope', 'simple'); if (count($this->Get('scope')->GetValues()) == 0) { $this->Set('scope', 'SMTP, IMAP'); } } else { $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'); } } ]]> false public Overload-DBObject false public Overload-DBObject false public false public Get('advanced_scope'))) { return $this->Get('advanced_scope'); } $aScopes = $this->Get('scope')->GetValues(); $aRawScopes = ['offline_access']; foreach ($aScopes as $sScope) { switch ($sScope) { case 'SMTP': $aRawScopes[] = 'https://outlook.office.com/SMTP.Send'; break; case 'IMAP': $aRawScopes[] = 'https://outlook.office.com/IMAP.AccessAsUser.All'; break; } } return implode(' ', $aRawScopes); } ]]>
OAuthClient grant_by_profile,application false autoincrement priv_oauth_client_google id true true SMTP IMAP scope SMTP,IMAP true advanced_scope true true simple advanced used_scope simple false true yes no used_for_smtp no true
10 10 10 20 30 40 50 60 70 80 20 10 10 20 30 40
10 10 10 10 10
false public Overload-DBObject Set('provider', 'Google'); $this->Set('redirect_url', Combodo\iTop\Core\Authentication\Client\OAuth\OAuthClientProviderFactory::GetRedirectUri()); $this->Set('scope', 'SMTP, IMAP'); parent::PrefillCreationForm($aContextParam); } ]]> false public Overload-DBObject ListChanges(); 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) { $this->m_aCheckIssues[] = Dict::Format('OAuthClient:Name/UseForSMTPMustBeUnique', $sNewName, $sNewUseForSMTP); } } } } ]]> false public Overload-DBObject Get('provider'))) { $this->Set('provider', 'Google'); } if (empty($this->Get('redirect_url'))) { $this->Set('redirect_url', Combodo\iTop\Core\Authentication\Client\OAuth\OAuthClientProviderFactory::GetRedirectUri()); } if (empty($this->Get('advanced_scope'))) { $this->Set('used_scope', 'simple'); if (count($this->Get('scope')->GetValues()) == 0) { $this->Set('scope', 'SMTP, IMAP'); } } else { $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'); } } ]]> false public Overload-DBObject false public Overload-DBObject false public false public Get('advanced_scope'))) { return $this->Get('advanced_scope'); } $aScopes = $this->Get('scope')->GetValues(); $aRawScopes = []; foreach ($aScopes as $sScope) { switch ($sScope) { case 'SMTP': $aRawScopes['https://mail.google.com/'] = 'https://mail.google.com/'; break; case 'IMAP': $aRawScopes['https://mail.google.com/'] = 'https://mail.google.com/'; break; } } return implode(' ', $aRawScopes); } ]]>
100 Integrations 1 0 OAuthClient UR_ACTION_MODIFY allow allow allow allow allow allow