コード例 #1
0
ファイル: GooglePlus.php プロジェクト: surfyst/oasys
 /**
  * Returns this user as a GenericUser
  *
  * @return UserLike
  * @throws OasysException
  * @throws \InvalidArgumentException
  */
 public function getUserData()
 {
     $_response = parent::getUserData();
     if (HttpResponse::Ok != ($_code = Option::get($_response, 'code', Curl::getLastHttpCode()))) {
         throw new OasysException('Unexpected response code', $_code, null, $_response);
     }
     $_profile = Option::get($_response, 'result');
     if (empty($_profile)) {
         throw new \InvalidArgumentException('No profile available to convert.');
     }
     $_profileId = Option::get($_profile, 'id');
     $_nameGoogle = Option::get($_profile, 'name');
     $_name = array('formatted' => Option::get($_profile, 'displayName'), 'familyName' => Option::get($_nameGoogle, 'familyName'), 'givenName' => Option::get($_nameGoogle, 'givenName'));
     $_email = null;
     // Get the account email. Google returns a list of emails.
     foreach (Option::get($_profile, 'emails') as $_emailIteration) {
         if (Option::get($_emailIteration, 'type') == 'account') {
             $_email = Option::get($_emailResult, 'value');
             break;
             // ugly, but works
         }
     }
     return new GenericUser(array('user_id' => $_profileId, 'name' => $_name, 'gender' => Option::get($_profile, 'gender'), 'email_address' => $_email, 'urls' => array(Option::get($_profile, 'url')), 'thumbnail_url' => Option::getDeep($_profile, 'image', 'url'), 'user_data' => $_profile));
 }
コード例 #2
0
ファイル: WebController.php プロジェクト: rascyber/dsp-core
 protected function _checkSystemState()
 {
     $_error = false;
     $_state = SystemManager::getSystemState();
     if (!$this->_activated && $_state != PlatformStates::INIT_REQUIRED) {
         $_state = PlatformStates::ADMIN_REQUIRED;
     }
     if (!empty($this->_remoteError)) {
         $_error = 'error=' . urlencode($this->_remoteError);
     }
     if (PlatformStates::READY == $_state) {
         $_defaultApp = Pii::getParam('dsp.default_app', static::DEFAULT_STARTUP_APP);
         //	Try local launchpad
         if (is_file(\Kisma::get('app.app_path') . $_defaultApp)) {
             $_defaultApp = rtrim($_defaultApp . Curl::urlSeparator($_defaultApp) . $_error, '?');
             $this->redirect($_defaultApp);
         }
         //            Log::notice(
         //                'No default application defined/found. Running launchpad...' .
         //                PHP_EOL .
         //                '==============================' .
         //                PHP_EOL .
         //                'Config dump:' .
         //                PHP_EOL .
         //                print_r( \Kisma::get( null ), true ) .
         //                '==============================' .
         //                PHP_EOL .
         //                '==============================' .
         //                PHP_EOL .
         //                'Params dump:' .
         //                PHP_EOL .
         //                print_r( Pii::params(), true ) .
         //                '==============================' .
         //                PHP_EOL
         //            );
         //	If we have no app, run the launchpad
         $this->redirect(static::DEFAULT_STARTUP_APP);
     } else {
         if (!$this->_handleAction($_state)) {
             Log::error('Invalid state "' . $_state . '" or no handler configured.');
         }
     }
 }
コード例 #3
0
ファイル: BaseProvider.php プロジェクト: surfyst/oasys
 /**
  * Execute a request
  *
  * @param string $url         Request URL
  * @param mixed  $payload     The payload to send
  * @param string $method      The HTTP method to send
  * @param array  $headers     Array of HTTP headers to send in array( 'header: value', 'header: value', ... ) format
  * @param array  $curlOptions Array of options to pass to CURL
  *
  * @throws AuthenticationException
  * @return array
  */
 protected function _makeRequest($url, array $payload = array(), $method = self::Get, array $headers = array(), array $curlOptions = array())
 {
     static $_defaultCurlOptions = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => 0);
     //	Start clean...
     $this->_resetRequest();
     //	Add in any user-supplied CURL options
     $_curlOptions = array_merge($_defaultCurlOptions, $curlOptions);
     //	Add certificate info for SSL
     if (null !== ($_certificateFile = $this->getConfig('certificate_file'))) {
         $_curlOptions[CURLOPT_SSL_VERIFYPEER] = true;
         $_curlOptions[CURLOPT_SSL_VERIFYHOST] = 2;
         $_curlOptions[CURLOPT_CAINFO] = $_certificateFile;
     }
     //	And finally our headers
     if (null !== ($_agent = $this->getConfig('user_agent'))) {
         $headers[] = 'User-Agent: ' . $_agent;
     }
     $_curlOptions[CURLOPT_HTTPHEADER] = $headers;
     //	Convert payload to query string for a GET
     if (static::Get == $method && !empty($payload)) {
         $url .= (false === strpos($url, '?') ? '?' : '&') . http_build_query($payload);
         $payload = array();
     }
     //	And finally make the request
     if (false === ($_result = Curl::request($method, $url, $this->_translatePayload($payload, false), $_curlOptions))) {
         throw new AuthenticationException(Curl::getErrorAsString());
     }
     //	Save off response
     $this->_lastResponseCode = $_code = Curl::getLastHttpCode();
     //	Shift result from array...
     if (is_array($_result) && isset($_result[0]) && sizeof($_result) == 1 && $_result[0] instanceof \stdClass) {
         $_result = $_result[0];
     }
     $_contentType = Curl::getInfo('content_type');
     if (DataFormatTypes::JSON == $this->_responseFormat && false !== stripos($_contentType, 'application/json', 0)) {
         $_result = $this->_translatePayload($_result);
     }
     return $this->_lastResponse = array('result' => $_result, 'code' => $_code, 'content_type' => $_contentType);
 }
コード例 #4
0
ファイル: BaseOAuthProvider.php プロジェクト: surfyst/oasys
 /**
  * Construct a link to authorize the application
  *
  * @param array $payload
  *
  * @return string
  */
 public function getAuthorizationUrl($payload = array())
 {
     $_map = $this->_config->getEndpoint(EndpointTypes::AUTHORIZE);
     $_scope = $this->getConfig('scope');
     $_referrer = Option::get($this->_requestPayload, 'referrer', Option::server('HTTP_REFERER', Curl::currentUrl()), true);
     $_redirectUri = $this->getConfig('redirect_uri', $_referrer);
     $_origin = $this->getConfig('origin_uri', $_redirectUri);
     $_proxyUrl = $this->getConfig('redirect_proxy_url');
     $_state = array('request' => array('method' => Option::server('REQUEST_METHOD'), 'referrer' => $_referrer, 'query_string' => Option::server('QUERY_STRING'), 'remote_addr' => Option::server('REMOTE_ADDR'), 'time' => microtime(true), 'uri' => Option::server('REQUEST_URI'), 'payload' => $this->_requestPayload), 'origin' => $_origin, 'api_key' => sha1($_origin), 'redirect_uri' => $_redirectUri);
     Log::debug('Request state built: ' . print_r($_state, true));
     $_payload = array_merge(array('client_id' => $this->getConfig('client_id'), 'redirect_uri' => $_redirectUri, 'response_type' => 'code', 'scope' => is_array($_scope) ? implode(' ', $_scope) : $_scope, 'state' => Storage::freeze($_state)), Option::clean(Option::get($_map, 'parameters', array())));
     if (!empty($_proxyUrl)) {
         Log::info('Proxying request through: ' . $_proxyUrl);
         $_payload['redirect_uri'] = $_proxyUrl;
     }
     $_qs = http_build_query($_payload);
     $this->setConfig('authorize_url', $_authorizeUrl = $_map['endpoint'] . Curl::urlSeparator($_map['endpoint']) . $_qs);
     Log::debug('Authorization URL created: ' . $_authorizeUrl);
     return $_authorizeUrl;
 }
コード例 #5
0
ファイル: index.php プロジェクト: surfyst/portal-sandbox
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Footer -->
<?php 
include __DIR__ . '/views/_footer.php';
?>

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="//google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
<script src="js/app.jquery.js"></script>
<script>
//	This needs to be last because _options is defined in app.jquery.js... lame, I know...
_options.baseUrl = <?php 
echo "'" . Curl::currentUrl(false, false) . "'";
?>
;
_options.providers = <?php 
echo json_encode($_providerCache);
?>
;
</script>
</body>
</html>
コード例 #6
0
ファイル: oauth.schema.php プロジェクト: surfyst/oasys
 * This file is part of the DreamFactory Oasys (Open Authentication SYStem)
 *
 * DreamFactory Oasys (Open Authentication SYStem) <http://dreamfactorysoftware.github.io>
 * Copyright 2014 DreamFactory Software, Inc. <*****@*****.**>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
namespace DreamFactory\Oasys\Configs\Schemas;

/**
 * oauth.schema.php
 * The config schema for an OAuth service
 */
use DreamFactory\Oasys\Enums\AccessTypes;
use DreamFactory\Oasys\Enums\Flows;
use DreamFactory\Oasys\Enums\GrantTypes;
use DreamFactory\Oasys\Enums\OAuthTypes;
use DreamFactory\Oasys\Enums\TokenTypes;
use Kisma\Core\Utility\Curl;
return array('client_id' => array('type' => 'text', 'maxlength' => 64, 'class' => 'required'), 'client_secret' => array('type' => 'text', 'maxlength' => 128, 'class' => 'required'), 'redirect_uri' => array('type' => 'text', 'maxlength' => 1024, 'class' => 'required', 'placeholder' => Curl::currentUrl(false, false)), 'scope' => array('type' => 'textarea', 'hint' => 'Comma-separated list of desired scopes.'), 'certificate_file' => array('type' => 'textarea', 'maxlength' => 1024, 'placeholder' => 'Provider Default'), 'authorize_url' => array('type' => 'text', 'maxlength' => 1024, 'placeholder' => 'Provider Default'), 'grant_type' => array('type' => 'select', 'value' => GrantTypes::AUTHORIZATION_CODE, 'data' => GrantTypes::getDefinedConstants(true, null, true)), 'auth_type' => array('type' => 'select', 'value' => OAuthTypes::URI, 'data' => OAuthTypes::getDefinedConstants(true, null, true)), 'access_type' => array('type' => 'select', 'value' => AccessTypes::OFFLINE, 'data' => AccessTypes::getDefinedConstants(true, null, true)), 'flow_type' => array('type' => 'select', 'value' => Flows::SERVER_SIDE, 'data' => Flows::getDefinedConstants(true, null, true)), 'access_token_param_name' => array('type' => 'text', 'maxlength' => 64, 'hint' => 'The name of the parameter to use when sending the access token via URL.'), 'auth_header_name' => array('type' => 'text', 'maxlength' => 64, 'hint' => 'The name of the parameter to use when sending the access token via HTTP header.'), 'access_token_type' => array('type' => 'select', 'default' => TokenTypes::URI, 'data' => TokenTypes::getDefinedConstants(true, null, true), 'hint' => 'The type of, and way the provider expects to receive, the token.'), 'access_token' => array('type' => 'text', 'maxlength' => 128, 'placeholder' => 'Not Stored', 'private' => true), 'access_token_secret' => array('type' => 'text', 'maxlength' => 128, 'placeholder' => 'Not Stored', 'private' => true), 'access_token_expires' => array('type' => 'text', 'class' => 'number', 'private' => true), 'refresh_token' => array('type' => 'text', 'maxlength' => 128, 'private' => true), 'refresh_token_expires' => array('type' => 'text', 'class' => 'number', 'private' => true), 'redirect_proxy_url' => array('type' => 'text', 'maxlength' => 1024));
コード例 #7
0
ファイル: HttpService.php プロジェクト: kisma/kisma
 /**
  * @return int
  */
 public function getLastHttpCode()
 {
     return Curl::getLastHttpCode();
 }
コード例 #8
0
ファイル: Salesforce.php プロジェクト: surfyst/oasys
 /**
  * Response is always empty from this call. HTTP response code of 204 is success. Anything is an error.
  *
  * @param string $object
  * @param string $id
  * @param array  $fields
  *
  * @throws InternalServerErrorException
  * @return bool|mixed
  */
 public function updateObject($object, $id, $fields = array())
 {
     $_response = $this->fetch('/services/data/' . static::API_VERSION_TAG . '/sobjects/' . $object . '/' . $id, json_encode($fields), static::Patch);
     //	Curl error is false...
     if (false === $_response) {
         return false;
     }
     if (HttpResponse::NoContent == Curl::getLastHttpCode()) {
         return true;
     }
     //	Sometimes they send back xml...
     if (is_string($_response) && false !== stripos($_response, '<?xml')) {
         try {
             if (null === ($_response = Convert::toObject(simplexml_load_string($_response)))) {
                 throw new InternalServerErrorException('Unrecognizable response from server: ' . print_r($_response, true));
             }
             //	Otherwise we have a nice object which we return as json
         } catch (\Exception $_ex) {
             //	error...
             Log::error('Exception parsing response: ' . print_r($_response, true));
         }
     }
     return $_response;
 }
コード例 #9
0
ファイル: Facebook.php プロジェクト: surfyst/oasys
 /**
  * Returns this user as a GenericUser
  *
  *
  * @throws \DreamFactory\Oasys\Exceptions\OasysException
  * @throws \InvalidArgumentException
  * @return UserLike
  */
 public function getUserData()
 {
     $_response = parent::getUserData();
     if (HttpResponse::Ok != ($_code = Option::get($_response, 'code', Curl::getLastHttpCode()))) {
         throw new OasysException('Unexpected response code', $_code, null, $_response);
     }
     $_profile = Option::get($_response, 'result');
     if (empty($_profile)) {
         throw new \InvalidArgumentException('No profile available to convert.');
     }
     $_profileId = Option::get($_profile, 'id');
     $_name = array('formatted' => Option::get($_profile, 'name'), 'familyName' => Option::get($_profile, 'last_name'), 'givenName' => Option::get($_profile, 'first_name'));
     return new GenericUser(array('user_id' => $_profileId, 'published' => Option::get($_profile, 'updated_time'), 'updated' => Option::get($_profile, 'updated_time'), 'display_name' => $_name['formatted'], 'name' => $_name, 'preferred_username' => Option::get($_profile, 'username'), 'gender' => Option::get($_profile, 'gender'), 'email_address' => Option::get($_profile, 'email'), 'urls' => array(Option::get($_profile, 'link')), 'relationships' => Option::get($_profile, 'friends'), 'thumbnail_url' => $this->_config->getEndpointUrl() . '/' . $_profileId . '/picture?width=150&height=150', 'user_data' => $_profile));
 }
コード例 #10
0
ファイル: mobile.php プロジェクト: digideskio/dsp-core
$_step = 'light';
$_headline = 'DSP Settings';
$_themeList = null;
//	Change these to update the CDN versions used. Set to false to disable
$_bootstrapVersion = '3.1.1';
// Set to false to disable
$_bootswatchVersion = '3.1.1';
$_dataTablesVersion = '1.9.4';
$_bootswatchTheme = FilterInput::request('theme', Pii::getState('admin.default_theme', 'default'), FILTER_SANITIZE_STRING);
Pii::setState('dsp.admin_theme', $_bootswatchTheme);
$_useBootswatchThemes = 'default' != $_bootswatchTheme;
$_fontAwesomeVersion = '4.0.3';
// Set to false to disable
$_jqueryVersion = '1.11.0';
$_themes = array('Default', 'Amelia', 'Cerulean', 'Cosmo', 'Cyborg', 'Flatly', 'Journal', 'Readable', 'Simplex', 'Slate', 'Spacelab', 'United');
$_url = Curl::currentUrl(false);
foreach ($_themes as $_item) {
    $_name = strtolower($_item);
    $_class = $_bootswatchTheme == $_name ? 'class="active"' : null;
    $_themeList .= <<<HTML
\t<li {$_class}><a href="{$_url}?theme={$_name}">{$_item}</a></li>
HTML;
}
//	Our css building begins...
$_css = '<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700,800" rel="stylesheet" type="text/css">';
$_scripts = null;
if ($_useBootswatchThemes) {
    $_css .= '<link href="//netdna.bootstrapcdn.com/bootswatch/' . $_bootswatchVersion . '/' . $_bootswatchTheme . '/bootstrap.min.css" rel="stylesheet" media="screen">';
} else {
    if (false !== $_bootstrapVersion) {
        $_css .= '<link href="//netdna.bootstrapcdn.com/bootstrap/' . $_bootstrapVersion . '/css/bootstrap.min.css" rel="stylesheet"  media="screen">';