From 20dac3e836a02b57794559bb0501c356cd140459 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 17 Jan 2014 15:31:56 +0000 Subject: [PATCH] Remove GitHub OTP code from RFS class --- src/Composer/Util/RemoteFilesystem.php | 48 -------------------------- 1 file changed, 48 deletions(-) diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index 890bd5aad..d3ecec03d 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -145,42 +145,6 @@ class RemoteFilesystem if ($e instanceof TransportException && !empty($http_response_header[0])) { $e->setHeaders($http_response_header); } - - // 401 when authentication was supplied, handle 2FA if required. - if ($e instanceof TransportException && 401 === $e->getCode() && $this->io->hasAuthentication($this->originUrl)) { - $headerNames = array_map(function($header) { - return strstr($header, ':', true); - }, $e->getHeaders()); - - if ($key = array_search('X-GitHub-OTP', $headerNames)) { - $headers = $e->getHeaders(); - list($required, $method) = array_map('trim', explode(';', substr(strstr($headers[$key], ':'), 1))); - - if ('required' === $required) { - $this->io->write('Two-factor Authentication'); - - if ('app' === $method) { - $this->io->write('Open the two-factor authentication app on your device to view your authentication code and verify your identity.'); - } - - if ('sms' === $method) { - // @todo - } - - $this->options['github-otp'] = trim($this->io->ask('Authentication Code: ')); - - $this->retry = true; - } - } else { - try { - $this->promptAuthAndRetry(); - } catch (TransportException $e) { - if ($e instanceof TransportException && !empty($http_response_header[0])) { - $e->setHeaders($http_response_header); - } - } - } - } } if ($errorMessage && !ini_get('allow_url_fopen')) { $errorMessage = 'allow_url_fopen must be enabled in php.ini ('.$errorMessage.')'; @@ -283,11 +247,6 @@ class RemoteFilesystem throw new TransportException($message, 401); } - // GitHub requests bail out early to allow 2FA to be applied if requested. - if ('github.com' === $this->originUrl) { - throw new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.trim($message).')', 401); - } - $this->promptAuthAndRetry(); break; } @@ -378,13 +337,6 @@ class RemoteFilesystem } } - // Handle GitHub two factor tokens. - if (isset($options['github-otp'])) { - $headers[] = 'X-GitHub-OTP: ' . $options['github-otp']; - - unset($options['github-otp']); - } - if (isset($options['http']['header']) && !is_array($options['http']['header'])) { $options['http']['header'] = explode("\r\n", trim($options['http']['header'], "\r\n")); }