Пример #1
0
 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.');
         }
     }
 }
Пример #2
0
 /**
  * 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;
 }