InstallationManager: notifyInstalls: append authorization header for repository
parent
f85d965732
commit
b05b52ff7e
|
@ -318,7 +318,7 @@ EOT
|
||||||
$im = $this->createInstallationManager();
|
$im = $this->createInstallationManager();
|
||||||
$im->addInstaller($projectInstaller);
|
$im->addInstaller($projectInstaller);
|
||||||
$im->install(new InstalledFilesystemRepository(new JsonFile('php://memory')), new InstallOperation($package));
|
$im->install(new InstalledFilesystemRepository(new JsonFile('php://memory')), new InstallOperation($package));
|
||||||
$im->notifyInstalls();
|
$im->notifyInstalls($io);
|
||||||
|
|
||||||
$installedFromVcs = 'source' === $package->getInstallationSource();
|
$installedFromVcs = 'source' === $package->getInstallationSource();
|
||||||
|
|
||||||
|
|
|
@ -234,11 +234,11 @@ class Installer
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->installationManager->notifyInstalls();
|
$this->installationManager->notifyInstalls($this->io);
|
||||||
|
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
$this->installationManager->notifyInstalls();
|
$this->installationManager->notifyInstalls($this->io);
|
||||||
|
|
||||||
// output suggestions if we're in dev mode
|
// output suggestions if we're in dev mode
|
||||||
if ($this->devMode) {
|
if ($this->devMode) {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
namespace Composer\Installer;
|
namespace Composer\Installer;
|
||||||
|
|
||||||
|
use Composer\IO\IOInterface;
|
||||||
use Composer\Package\PackageInterface;
|
use Composer\Package\PackageInterface;
|
||||||
use Composer\Package\AliasPackage;
|
use Composer\Package\AliasPackage;
|
||||||
use Composer\Repository\RepositoryInterface;
|
use Composer\Repository\RepositoryInterface;
|
||||||
|
@ -230,9 +231,17 @@ class InstallationManager
|
||||||
return $installer->getInstallPath($package);
|
return $installer->getInstallPath($package);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function notifyInstalls()
|
public function notifyInstalls(IOInterface $io)
|
||||||
{
|
{
|
||||||
foreach ($this->notifiablePackages as $repoUrl => $packages) {
|
foreach ($this->notifiablePackages as $repoUrl => $packages) {
|
||||||
|
$repositoryName = parse_url ($repoUrl, PHP_URL_HOST);
|
||||||
|
if ($io->hasAuthentication ($repositoryName))
|
||||||
|
{
|
||||||
|
$auth = $io->getAuthentication ($repositoryName);
|
||||||
|
$authStr = base64_encode($auth['username'] . ':' . $auth['password']);
|
||||||
|
$authHeader = 'Authorization: Basic '.$authStr;
|
||||||
|
}
|
||||||
|
|
||||||
// non-batch API, deprecated
|
// non-batch API, deprecated
|
||||||
if (strpos($repoUrl, '%package%')) {
|
if (strpos($repoUrl, '%package%')) {
|
||||||
foreach ($packages as $package) {
|
foreach ($packages as $package) {
|
||||||
|
@ -250,6 +259,9 @@ class InstallationManager
|
||||||
'timeout' => 3,
|
'timeout' => 3,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
if (isset($authHeader)) {
|
||||||
|
$opts['http']['header'][] = $authHeader;
|
||||||
|
}
|
||||||
|
|
||||||
$context = StreamContextFactory::getContext($url, $opts);
|
$context = StreamContextFactory::getContext($url, $opts);
|
||||||
@file_get_contents($url, false, $context);
|
@file_get_contents($url, false, $context);
|
||||||
|
@ -274,6 +286,9 @@ class InstallationManager
|
||||||
'timeout' => 6,
|
'timeout' => 6,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
if (isset($authHeader)) {
|
||||||
|
$opts['http']['header'][] = $authHeader;
|
||||||
|
}
|
||||||
|
|
||||||
$context = StreamContextFactory::getContext($repoUrl, $opts);
|
$context = StreamContextFactory::getContext($repoUrl, $opts);
|
||||||
@file_get_contents($repoUrl, false, $context);
|
@file_get_contents($repoUrl, false, $context);
|
||||||
|
|
Loading…
Reference in New Issue