Allow OAuth2 authentication to downloads on api.github.com not just github.com
parent
308e2ff4cb
commit
1ce7c28f11
|
@ -85,6 +85,11 @@ class FileDownloader implements DownloaderInterface
|
||||||
$this->io->write(" - Installing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
|
$this->io->write(" - Installing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
|
||||||
|
|
||||||
$processUrl = $this->processUrl($package, $url);
|
$processUrl = $this->processUrl($package, $url);
|
||||||
|
$processHost = parse_url($processUrl, PHP_URL_HOST);
|
||||||
|
|
||||||
|
if (strpos($processHost, 'github.com') === (strlen($processHost) - 10)) {
|
||||||
|
$processHost = 'github.com';
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
|
@ -95,15 +100,15 @@ class FileDownloader implements DownloaderInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (TransportException $e) {
|
} catch (TransportException $e) {
|
||||||
if (404 === $e->getCode() && 'github.com' === parse_url($processUrl, PHP_URL_HOST)) {
|
if (404 === $e->getCode() && 'github.com' === $processHost) {
|
||||||
$message = "\n".'Could not fetch '.$processUrl.', enter your GitHub credentials to access private repos';
|
$message = "\n".'Could not fetch '.$processUrl.', enter your GitHub credentials to access private repos';
|
||||||
$gitHubUtil = new GitHub($this->io, $this->config, null, $this->rfs);
|
$gitHubUtil = new GitHub($this->io, $this->config, null, $this->rfs);
|
||||||
if (!$gitHubUtil->authorizeOAuth('github.com')
|
if (!$gitHubUtil->authorizeOAuth($processHost)
|
||||||
&& (!$this->io->isInteractive() || !$gitHubUtil->authorizeOAuthInteractively('github.com', $message))
|
&& (!$this->io->isInteractive() || !$gitHubUtil->authorizeOAuthInteractively($processHost, $message))
|
||||||
) {
|
) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
$this->rfs->copy(parse_url($processUrl, PHP_URL_HOST), $processUrl, $fileName);
|
$this->rfs->copy($processHost, $processUrl, $fileName);
|
||||||
} else {
|
} else {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue