/** * Tries to authorize user using netrc credentials * * @param PreFileDownloadEvent $event event contains information about host for authorization */ public function onPreFileDownload(PreFileDownloadEvent $event) { // parse host $host = parse_url($event->getProcessedUrl(), PHP_URL_HOST); if (!$host) { if ($this->io->isVerbose()) { $this->io->write(sprintf("<warning>Cannot authenticate user via netrc credentials. Unable to fetch " . "host from processing url: %s</warning>", $event->getProcessedUrl())); } return; } // check that user is already authenticated if ($this->io->hasAuthentication($host)) { if ($this->io->isVerbose()) { $this->io->write(sprintf(" Skipping netrc authentication. User is already " . "authenticated on <comment>%s</comment>", $host)); } return; } // trying to authenticate user with netrc credentials try { $netrcParsed = $this->getParsedNetrc(); if (isset($netrcParsed[$host]['login']) && isset($netrcParsed[$host]['password'])) { $this->io->setAuthentication($host, $netrcParsed[$host]['login'], $netrcParsed[$host]['password']); $this->io->write(" <info>User successfully authenticated using netrc credentials</info>"); } else { if ($this->io->isVerbose()) { $this->io->write(sprintf("<warning>Cannot authenticate user via netrc credentials. " . "Unable to fetch user login or password for host %s</warning>", $host)); } } } catch (PluginRuntimeException $ex) { // we cannot authorize current user via netrc $this->io->write("<warning>Cannot authenticate user via netrc credentials. Is your netrc file valid?</warning>"); } }
public function onPreFileDownload(CPlugin\PreFileDownloadEvent $ev) { $url = $ev->getProcessedUrl(); if (preg_match('/^https?/', $url)) { $rfs = $ev->getRemoteFilesystem(); $ev->setRemoteFilesystem(new CurlRemoteFilesystem($this->io, $this->config, $rfs->getOptions())); } }
public function onPreFileDownload(CPlugin\PreFileDownloadEvent $ev) { $scheme = parse_url($ev->getProcessedUrl(), PHP_URL_SCHEME); if ($scheme === 'http' || $scheme === 'https') { $rfs = $ev->getRemoteFilesystem(); $ev->setRemoteFilesystem(new CurlRemoteFilesystem($this->io, $this->config, $rfs->getOptions())); } }
public function onPreFileDownload(PreFileDownloadEvent $event) { $protocol = parse_url($event->getProcessedUrl(), PHP_URL_SCHEME); if ($protocol === 's3') { $awsClient = new AwsClient($this->io, $this->composer->getConfig()); $s3RemoteFilesystem = new S3RemoteFilesystem($this->io, $this->composer->getConfig(), $event->getRemoteFilesystem()->getOptions(), $awsClient); $event->setRemoteFilesystem($s3RemoteFilesystem); } }
/** * Keep-Alived file downloader */ public function onPreFileDownload(CPlugin\PreFileDownloadEvent $ev) { if ($this->disabled) { return; } $rfs = $ev->getRemoteFilesystem(); $curlrfs = new CurlRemoteFilesystem($this->io, $this->config, $rfs->getOptions()); $ev->setRemoteFilesystem($curlrfs); }
public function onPreFileDownload(PreFileDownloadEvent $event) { $url = $event->getProcessedUrl(); $host = parse_url($url, PHP_URL_HOST); $protocol = parse_url($url, PHP_URL_SCHEME); if (in_array($host, $this->hosts, true) && ($protocol === 'http' || $protocol === 'https')) { $orig = $event->getRemoteFilesystem(); $curl = new CurlRemoteFilesystem($this->curlClient, $this->io, $this->composer->getConfig(), $orig->getOptions()); $event->setRemoteFilesystem($curl); } }
public function onPreFileDownload(PreFileDownloadEvent $event) { $downloadReplacements = $this->composer->getConfig()->get('download-replacements'); $searched = false; foreach ($downloadReplacements as $search => $replacement) { if (strpos($event->getProcessedUrl(), $search) === 0) { $searched = true; break; } } if ($searched) { $qiniu = new FileSystem($this->io, $this->composer->getConfig(), $event->getRemoteFilesystem() ? $event->getRemoteFilesystem()->getOptions() : array()); $qiniu->setConfig($this->composer->getConfig()); $event->setRemoteFilesystem($qiniu); } }
/** * Add the key from the environment to the event url * * The key is not added to the package because it would show up in the * composer.lock file in this case. A custom file system is used to * swap out the WPM PRO url with a url that contains the key. * * @access public * @param PreFileDownloadEvent $event The event that called this method * @throws MissingKeyException */ public function addKey(PreFileDownloadEvent $event) { $processedUrl = $event->getProcessedUrl(); if ($this->isWPMProPackageUrl($processedUrl)) { $processedUrl = $processedUrl . 'site_url=' . $this->getSiteUrlFromEnv(); $rfs = $event->getRemoteFilesystem(); $wpmRfs = new RemoteFilesystem($this->addParameterToUrl($processedUrl, 'licence_key', $this->getKeyFromEnv()), $this->io, $this->composer->getConfig(), $rfs->getOptions(), $rfs->isTlsDisabled()); $event->setRemoteFilesystem($wpmRfs); } }
/** * Add the key from the environment to the event url * * The key is not added to the package because it would show up in the * composer.lock file in this case. A custom file system is used to * swap out the ACF PRO url with a url that contains the key. * * @access public * @param PreFileDownloadEvent $event The event that called this method * @throws MissingKeyException */ public function addKey(PreFileDownloadEvent $event) { $processedUrl = $event->getProcessedUrl(); if ($this->isAcfProPackageUrl($processedUrl)) { $rfs = $event->getRemoteFilesystem(); $acfRfs = new RemoteFilesystem($this->addParameterToUrl($processedUrl, 'k', $this->getKeyFromEnv()), $this->io, $this->composer->getConfig(), $rfs->getOptions(), $rfs->isTlsDisabled()); $event->setRemoteFilesystem($acfRfs); } }
/** * Set the remote filesystem for scp files. */ public function setRfs(PreFileDownloadEvent $event) { static $rfs; // is this an ssh url? if (strpos($event->getProcessedUrl(), 'ssh://') === 0) { if (!$rfs) { $rfs = new SSHFilesystem($this->io); } $event->setRemoteFilesystem($rfs); } }