Remove GitHub OTP code from RFS class
parent
9a0f4392da
commit
20dac3e836
|
@ -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"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue