Beispiel #1
0
 public function setUp()
 {
     if (!SugarOAuthServer::enabled() || !extension_loaded('oauth')) {
         $this->markTestSkipped("No OAuth support");
     }
     $this->oauth = new OAuth('TESTCUSTOMER', 'TESTSECRET', OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
     $this->url = rtrim($GLOBALS['sugar_config']['site_url'], '/') . '/service/v4/rest.php';
     $GLOBALS['current_user'] = self::$_user;
 }
 public function display()
 {
     if (!SugarOAuthServer::enabled()) {
         sugar_die($GLOBALS['mod_strings']['LBL_OAUTH_DISABLED']);
     }
     global $current_user;
     if (!isset($_REQUEST['token']) && isset($_REQUEST['oauth_token'])) {
         $_REQUEST['token'] = $_REQUEST['oauth_token'];
     }
     $sugar_smarty = new Sugar_Smarty();
     $sugar_smarty->assign('APP', $GLOBALS['app_strings']);
     $sugar_smarty->assign('MOD', $GLOBALS['mod_strings']);
     $sugar_smarty->assign('token', $_REQUEST['token']);
     $sugar_smarty->assign('sid', session_id());
     $token = OAuthToken::load($_REQUEST['token']);
     if (empty($token) || empty($token->consumer) || $token->tstate != OAuthToken::REQUEST || empty($token->consumer_obj)) {
         sugar_die('Invalid token');
     }
     if (empty($_REQUEST['confirm'])) {
         $sugar_smarty->assign('consumer', sprintf($GLOBALS['mod_strings']['LBL_OAUTH_CONSUMERREQ'], $token->consumer_obj->name));
         // SM: roles disabled for now
         //            $roles = array('' => '');
         //            $allroles = ACLRole::getAllRoles();
         //            foreach($allroles as $role) {
         //                $roles[$role->id] = $role->name;
         //            }
         //            $sugar_smarty->assign('roles', $roles);
         $hash = md5(rand());
         $_SESSION['oauth_hash'] = $hash;
         $sugar_smarty->assign('hash', $hash);
         echo $sugar_smarty->fetch('modules/OAuthTokens/tpl/authorize.tpl');
     } else {
         if ($_REQUEST['sid'] != session_id() || $_SESSION['oauth_hash'] != $_REQUEST['hash']) {
             sugar_die('Invalid request');
         }
         $verify = $token->authorize(array("user" => $current_user->id));
         if (!empty($token->callback_url)) {
             $redirect_url = $token->callback_url;
             if (strchr($redirect_url, "?") !== false) {
                 $redirect_url .= '&';
             } else {
                 $redirect_url .= '?';
             }
             $redirect_url .= "oauth_verifier=" . $verify . '&oauth_token=' . $_REQUEST['token'];
             SugarApplication::redirect($redirect_url);
         }
         $sugar_smarty->assign('VERIFY', $verify);
         $sugar_smarty->assign('token', '');
         echo $sugar_smarty->fetch('modules/OAuthTokens/tpl/authorized.tpl');
     }
 }
Beispiel #3
0
    $admin_option_defs['Administration']['backup_management'] = array('Backups', 'LBL_BACKUPS_TITLE', 'LBL_BACKUPS', './index.php?module=Administration&action=Backups');
}
$admin_option_defs['Administration']['languages'] = array('Currencies', 'LBL_MANAGE_LANGUAGES', 'LBL_LANGUAGES', './index.php?module=Administration&action=Languages&view=default');
$admin_option_defs['Administration']['repair'] = array('Repair', 'LBL_UPGRADE_TITLE', 'LBL_UPGRADE', './index.php?module=Administration&action=Upgrade');
$admin_option_defs['Administration']['global_search'] = array('icon_SearchForm', 'LBL_GLOBAL_SEARCH_SETTINGS', 'LBL_GLOBAL_SEARCH_SETTINGS_DESC', './index.php?module=Administration&action=GlobalSearchSettings');
if (!isset($GLOBALS['sugar_config']['hide_admin_diagnostics']) || !$GLOBALS['sugar_config']['hide_admin_diagnostics']) {
    $admin_option_defs['Administration']['diagnostic'] = array('Diagnostic', 'LBL_DIAGNOSTIC_TITLE', 'LBL_DIAGNOSTIC_DESC', './index.php?module=Administration&action=Diagnostic');
}
// Connector Integration
$admin_option_defs['Administration']['connector_settings'] = array('icon_Connectors', 'LBL_CONNECTOR_SETTINGS', 'LBL_CONNECTOR_SETTINGS_DESC', './index.php?module=Connectors&action=ConnectorSettings');
// Theme Enable/Disable
$admin_option_defs['Administration']['theme_settings'] = array('icon_AdminThemes', 'LBL_THEME_SETTINGS', 'LBL_THEME_SETTINGS_DESC', './index.php?module=Administration&action=ThemeSettings');
$admin_option_defs['Administration']['scheduler'] = array('Schedulers', 'LBL_SUGAR_SCHEDULER_TITLE', 'LBL_SUGAR_SCHEDULER', './index.php?module=Schedulers&action=index');
$admin_option_defs['Administration']['feed_settings'] = array('icon_SugarFeed', 'LBL_SUGARFEED_SETTINGS', 'LBL_SUGARFEED_SETTINGS_DESC', './index.php?module=SugarFeed&action=AdminSettings');
require_once 'include/SugarOAuthServer.php';
if (SugarOAuthServer::enabled()) {
    $admin_option_defs['Administration']['oauth'] = array('Password', 'LBL_OAUTH_TITLE', 'LBL_OAUTH', './index.php?module=OAuthKeys&action=index');
}
$admin_group_header[] = array('LBL_ADMINISTRATION_HOME_TITLE', '', false, $admin_option_defs, 'LBL_ADMINISTRATION_HOME_DESC');
//email manager.
$admin_option_defs = array();
$admin_option_defs['Emails']['mass_Email_config'] = array('EmailMan', 'LBL_MASS_EMAIL_CONFIG_TITLE', 'LBL_MASS_EMAIL_CONFIG_DESC', './index.php?module=EmailMan&action=config');
$admin_option_defs['Campaigns']['campaignconfig'] = array('Campaigns', 'LBL_CAMPAIGN_CONFIG_TITLE', 'LBL_CAMPAIGN_CONFIG_DESC', './index.php?module=EmailMan&action=campaignconfig');
$admin_option_defs['Emails']['mailboxes'] = array('InboundEmail', 'LBL_MANAGE_MAILBOX', 'LBL_MAILBOX_DESC', './index.php?module=InboundEmail&action=index');
$admin_option_defs['Campaigns']['mass_Email'] = array('EmailMan', 'LBL_MASS_EMAIL_MANAGER_TITLE', 'LBL_MASS_EMAIL_MANAGER_DESC', './index.php?module=EmailMan&action=index');
$admin_group_header[] = array('LBL_EMAIL_TITLE', '', false, $admin_option_defs, 'LBL_EMAIL_DESC');
//studio.
$admin_option_defs = array();
$admin_option_defs['studio']['studio'] = array('Studio', 'LBL_STUDIO', 'LBL_STUDIO_DESC', './index.php?module=ModuleBuilder&action=index&type=studio');
if (isset($GLOBALS['beanFiles']['iFrame'])) {
    $admin_option_defs['Administration']['portal'] = array('iFrames', 'LBL_IFRAME', 'DESC_IFRAME', './index.php?module=iFrames&action=index');
 /**
  * Get OAuth access token
  */
 public function oauth_access_token()
 {
     $GLOBALS['log']->info('Begin: SugarWebServiceImpl->oauth_access_token');
     require_once "include/SugarOAuthServer.php";
     try {
         $oauth = new SugarOAuthServer();
         $result = $oauth->accessToken();
     } catch (OAuthException $e) {
         $GLOBALS['log']->debug("OAUTH Exception: {$e}");
         $errorObject = new SoapError();
         $errorObject->set_error('invalid_login');
         self::$helperObject->setFaultObject($errorObject);
         $result = null;
     }
     $GLOBALS['log']->info('End: SugarWebServiceImpl->oauth_access_token');
     return $result;
 }
 public function checkOAuthAccess($errorObject)
 {
     require_once "include/SugarOAuthServer.php";
     try {
         $oauth = new SugarOAuthServer();
         $token = $oauth->authorizedToken();
         if (empty($token) || empty($token->assigned_user_id)) {
             return false;
         }
     } catch (OAuthException $e) {
         $GLOBALS['log']->debug("OAUTH Exception: {$e}");
         $errorObject->set_error('invalid_login');
         $this->setFaultObject($errorObject);
         return false;
     } catch (Zend_Oauth_Exception $e) {
         $GLOBALS['log']->debug("Zend_Oauth_Exception: {$e}");
         $errorObject->set_error('invalid_login');
         $this->setFaultObject($errorObject);
         return false;
     }
     $user = BeanFactory::getBean('Users', $token->assigned_user_id);
     if (empty($user->id)) {
         return false;
     }
     global $current_user;
     $current_user = $user;
     ini_set("session.use_cookies", 0);
     // disable cookies to prevent session ID from going out
     session_start();
     session_regenerate_id();
     $_SESSION['oauth'] = $oauth->authorization();
     $_SESSION['avail_modules'] = $this->get_user_module_list($user);
     // TODO: handle role
     // handle session
     $_SESSION['is_valid_session'] = true;
     $_SESSION['ip_address'] = query_client_ip();
     $_SESSION['user_id'] = $current_user->id;
     $_SESSION['type'] = 'user';
     $_SESSION['authenticated_user_id'] = $current_user->id;
     return session_id();
 }