Ejemplo n.º 1
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;
 }
 /**
  * @param PackageInterface $package
  *
  * @throws \InvalidArgumentException
  * @return string
  */
 protected function _validatePackage(PackageInterface $package)
 {
     $_packageName = $package->getPrettyName();
     $_parts = explode('/', $_packageName, 2);
     $this->_extra = Option::clean($package->getExtra());
     $this->_config = Option::get($this->_extra, 'config', array());
     $this->_plugIn = static::DSP_PLUGIN_PACKAGE_TYPE == $package->getType();
     //	Only install DreamFactory packages if not a plug-in
     if (static::PACKAGE_PREFIX != ($_vendor = @current($_parts)) && !$this->_plugIn) {
         throw new \InvalidArgumentException('This package is not a DreamFactory package and cannot be installed by this installer.' . PHP_EOL . '  * Name: ' . $_packageName . PHP_EOL . '  * Parts: ' . implode(' / ', $_parts) . PHP_EOL);
     }
     //	Effectively /docRoot/shared/[vendor]/[namespace]/[package]
     Log::debug('Package "' . $_packageName . '" installation type: ' . ($this->_plugIn ? 'Plug-in' : 'Package'));
     $this->_packageName = $_packageName;
     $this->_installPath = $this->_buildInstallPath($_vendor, @end($_parts));
     //	Link path for plug-ins
     $_extra = Option::clean($package->getExtra());
     $this->_linkName = Option::get($_extra, 'link_name', $_parts[1]);
     //	Relative to composer.json... i.e. web/[link_name]
     $this->_linkPath = trim(static::PLUG_IN_LINK_PATH . '/' . $this->_linkName, '/');
     Log::info('Platform Installer Debug > ' . $_packageName . ' > Version ' . $package->getVersion());
     Log::debug('  * Install path: ' . $this->_installPath);
     if ($this->_plugIn) {
         Log::debug('  *    Link name: ' . $this->_linkName);
         Log::debug('  *    Link path: ' . $this->_linkPath);
     }
     return true;
 }