From 743153e862b7b82bd71f09be9775f460ca8d6ac0 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 29 Nov 2017 15:56:45 +0100 Subject: [PATCH] Tweak so that we allow authentication for domains we redirect to, refs #6717 --- src/Composer/Util/RemoteFilesystem.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index 82526e303..1ace44c96 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -247,17 +247,6 @@ class RemoteFilesystem unset($tempAdditionalOptions); $userlandFollow = isset($options['http']['follow_location']) && !$options['http']['follow_location']; - if ($isRedirect && $this->io->hasAuthentication($this->originUrl)) { - // Redirecting away from originUrl domain? Then remove the auth headers. - $redirectHost = parse_url($this->fileUrl, PHP_URL_HOST); - if ($this->originUrl != $redirectHost && stripos($redirectHost, '.' . $this->originUrl) === false) { - // Strip off authentication - $options['http']['header'] = array_filter($options['http']['header'], function($value){ - return stripos($value, 'Authorization') !== 0; - }); - } - } - $origFileUrl = $fileUrl; if (isset($options['github-token'])) { @@ -775,7 +764,7 @@ class RemoteFilesystem $authStr = base64_encode($auth['username'] . ':' . $auth['password']); $headers[] = 'Authorization: Basic '.$authStr; } - $userlandFollow = true; // always perform userland follow (to be able to change headers when redirected) + $userlandFollow = true; // always perform userland follow (to be able to change Authorization headers when redirected) } if (isset($userlandFollow)) { @@ -822,7 +811,7 @@ class RemoteFilesystem $additionalOptions['redirects'] = $this->redirects; - return $this->get($this->originUrl, $targetUrl, $additionalOptions, $this->fileName, $this->progress); + return $this->get(parse_url($targetUrl, PHP_URL_HOST), $targetUrl, $additionalOptions, $this->fileName, $this->progress); } if (!$this->retry) {