Add an option which causes reauth attempts to be bypassed
parent
20dac3e836
commit
3f6a62099d
|
@ -33,6 +33,7 @@ class RemoteFilesystem
|
||||||
private $progress;
|
private $progress;
|
||||||
private $lastProgress;
|
private $lastProgress;
|
||||||
private $options;
|
private $options;
|
||||||
|
private $retryAuthFailure;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -109,12 +110,19 @@ class RemoteFilesystem
|
||||||
$this->fileName = $fileName;
|
$this->fileName = $fileName;
|
||||||
$this->progress = $progress;
|
$this->progress = $progress;
|
||||||
$this->lastProgress = null;
|
$this->lastProgress = null;
|
||||||
|
$this->retryAuthFailure = true;
|
||||||
|
|
||||||
// capture username/password from URL if there is one
|
// capture username/password from URL if there is one
|
||||||
if (preg_match('{^https?://(.+):(.+)@([^/]+)}i', $fileUrl, $match)) {
|
if (preg_match('{^https?://(.+):(.+)@([^/]+)}i', $fileUrl, $match)) {
|
||||||
$this->io->setAuthentication($originUrl, urldecode($match[1]), urldecode($match[2]));
|
$this->io->setAuthentication($originUrl, urldecode($match[1]), urldecode($match[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($additionalOptions['retry-auth-failure'])) {
|
||||||
|
$this->retryAuthFailure = (bool) $additionalOptions['retry-auth-failure'];
|
||||||
|
|
||||||
|
unset($additionalOptions['retry-auth-failure']);
|
||||||
|
}
|
||||||
|
|
||||||
$options = $this->getOptionsForUrl($originUrl, $additionalOptions);
|
$options = $this->getOptionsForUrl($originUrl, $additionalOptions);
|
||||||
|
|
||||||
if ($this->io->isDebug()) {
|
if ($this->io->isDebug()) {
|
||||||
|
@ -247,6 +255,11 @@ class RemoteFilesystem
|
||||||
throw new TransportException($message, 401);
|
throw new TransportException($message, 401);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bail if the caller is going to handle authentication failures itself.
|
||||||
|
if (!$this->retryAuthFailure) {
|
||||||
|
throw new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.trim($message).')', 401);
|
||||||
|
}
|
||||||
|
|
||||||
$this->promptAuthAndRetry();
|
$this->promptAuthAndRetry();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue