diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index 2cae1414a..11a176389 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -318,7 +318,7 @@ EOT $im = $this->createInstallationManager(); $im->addInstaller($projectInstaller); $im->install(new InstalledFilesystemRepository(new JsonFile('php://memory')), new InstallOperation($package)); - $im->notifyInstalls(); + $im->notifyInstalls($io); $installedFromVcs = 'source' === $package->getInstallationSource(); diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 5f1299a97..505efca90 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -234,11 +234,11 @@ class Installer return $res; } } catch (\Exception $e) { - $this->installationManager->notifyInstalls(); + $this->installationManager->notifyInstalls($this->io); throw $e; } - $this->installationManager->notifyInstalls(); + $this->installationManager->notifyInstalls($this->io); // output suggestions if we're in dev mode if ($this->devMode) { diff --git a/src/Composer/Installer/InstallationManager.php b/src/Composer/Installer/InstallationManager.php index b774f83c9..e2dc01c51 100644 --- a/src/Composer/Installer/InstallationManager.php +++ b/src/Composer/Installer/InstallationManager.php @@ -12,6 +12,7 @@ namespace Composer\Installer; +use Composer\IO\IOInterface; use Composer\Package\PackageInterface; use Composer\Package\AliasPackage; use Composer\Repository\RepositoryInterface; @@ -230,9 +231,17 @@ class InstallationManager return $installer->getInstallPath($package); } - public function notifyInstalls() + public function notifyInstalls(IOInterface $io) { 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 if (strpos($repoUrl, '%package%')) { foreach ($packages as $package) { @@ -250,6 +259,9 @@ class InstallationManager 'timeout' => 3, ), ); + if (isset($authHeader)) { + $opts['http']['header'][] = $authHeader; + } $context = StreamContextFactory::getContext($url, $opts); @file_get_contents($url, false, $context); @@ -274,6 +286,9 @@ class InstallationManager 'timeout' => 6, ), ); + if (isset($authHeader)) { + $opts['http']['header'][] = $authHeader; + } $context = StreamContextFactory::getContext($repoUrl, $opts); @file_get_contents($repoUrl, false, $context);