Add repository stream context options
Add support for passing stream context options to the StreamContextFactory. This allows support for SSH keyfiles, SSL certificates and much more. Example: { "repositories": [ { "type": "composer", "url": "ssh2.sftp://host:22/path/to/packages.json", "options": { "ssh2": { "username": "composer", "pubkey_file": "/path/to/composer.key.pub", "privkey_file": "/path/to/composer.key" } } } ] }pull/1177/head
parent
4799053ca9
commit
6cf860669f
|
@ -27,6 +27,7 @@ use Composer\Util\RemoteFilesystem;
|
|||
class ComposerRepository extends ArrayRepository implements NotifiableRepositoryInterface, StreamableRepositoryInterface
|
||||
{
|
||||
protected $config;
|
||||
protected $options;
|
||||
protected $url;
|
||||
protected $io;
|
||||
protected $cache;
|
||||
|
@ -46,7 +47,12 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
|
|||
throw new \UnexpectedValueException('Invalid url given for Composer repository: '.$repoConfig['url']);
|
||||
}
|
||||
|
||||
if (!isset($repoConfig['options'])) {
|
||||
$repoConfig['options'] = array();
|
||||
}
|
||||
|
||||
$this->config = $config;
|
||||
$this->options = $repoConfig['options'];
|
||||
$this->url = $repoConfig['url'];
|
||||
$this->io = $io;
|
||||
$this->cache = new Cache($io, $config->get('home').'/cache/'.preg_replace('{[^a-z0-9.]}i', '-', $this->url));
|
||||
|
@ -199,7 +205,7 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
|
|||
$jsonUrl = $this->url . '/packages.json';
|
||||
}
|
||||
|
||||
$json = new JsonFile($jsonUrl, new RemoteFilesystem($this->io));
|
||||
$json = new JsonFile($jsonUrl, new RemoteFilesystem($this->io, $this->options));
|
||||
$data = $json->read();
|
||||
|
||||
if (!empty($data['notify'])) {
|
||||
|
|
|
@ -30,15 +30,17 @@ class RemoteFilesystem
|
|||
private $result;
|
||||
private $progress;
|
||||
private $lastProgress;
|
||||
private $options;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param IOInterface $io The IO instance
|
||||
*/
|
||||
public function __construct(IOInterface $io)
|
||||
public function __construct(IOInterface $io, $options = array())
|
||||
{
|
||||
$this->io = $io;
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -241,6 +243,8 @@ class RemoteFilesystem
|
|||
$options['http']['header'] .= "Authorization: Basic $authStr\r\n";
|
||||
}
|
||||
|
||||
$options = array_merge_recursive($options, $this->options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue