1
0
Fork 0

Remove GitHub OTP code from RFS class

pull/2577/head
Chris Smith 2014-01-17 15:31:56 +00:00
parent 9a0f4392da
commit 20dac3e836
1 changed files with 0 additions and 48 deletions

View File

@ -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"));
}