Merge pull request #3272 from bashofmann/master
Added cacheCredentials config flag for saved SVN credentialspull/3294/merge
commit
eba04dc211
|
@ -345,6 +345,37 @@ If the package is in a sub-directory, e.g. `/trunk/foo/bar/composer.json` and
|
||||||
setting the `"package-path"` option to the sub-directory, in this example it
|
setting the `"package-path"` option to the sub-directory, in this example it
|
||||||
would be `"package-path": "foo/bar/"`.
|
would be `"package-path": "foo/bar/"`.
|
||||||
|
|
||||||
|
If you have a private Subversion repository you can save credentials in the
|
||||||
|
http-basic section of your config (See [Schema](04-schema.md)):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"http-basic": {
|
||||||
|
"svn.example.org": {
|
||||||
|
"username": "username",
|
||||||
|
"password": "password"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
If your Subversion client is configured to store credentials by default these
|
||||||
|
credentials will be saved for the current user and existing saved credentials
|
||||||
|
for this server will be overwritten. To change this behavior by setting the
|
||||||
|
`"svn-cache-credentials"` option in your repository configuration:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "vcs",
|
||||||
|
"url": "http://svn.example.org/projectA/",
|
||||||
|
"svn-cache-credentials": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### PEAR
|
### PEAR
|
||||||
|
|
||||||
It is possible to install packages from any PEAR channel by using the `pear`
|
It is possible to install packages from any PEAR channel by using the `pear`
|
||||||
|
|
|
@ -27,6 +27,10 @@ use Composer\Downloader\TransportException;
|
||||||
*/
|
*/
|
||||||
class SvnDriver extends VcsDriver
|
class SvnDriver extends VcsDriver
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Cache
|
||||||
|
*/
|
||||||
protected $cache;
|
protected $cache;
|
||||||
protected $baseUrl;
|
protected $baseUrl;
|
||||||
protected $tags;
|
protected $tags;
|
||||||
|
@ -38,6 +42,7 @@ class SvnDriver extends VcsDriver
|
||||||
protected $branchesPath = 'branches';
|
protected $branchesPath = 'branches';
|
||||||
protected $tagsPath = 'tags';
|
protected $tagsPath = 'tags';
|
||||||
protected $packagePath = '';
|
protected $packagePath = '';
|
||||||
|
protected $cacheCredentials = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Composer\Util\Svn
|
* @var \Composer\Util\Svn
|
||||||
|
@ -62,6 +67,9 @@ class SvnDriver extends VcsDriver
|
||||||
if (isset($this->repoConfig['tags-path'])) {
|
if (isset($this->repoConfig['tags-path'])) {
|
||||||
$this->tagsPath = $this->repoConfig['tags-path'];
|
$this->tagsPath = $this->repoConfig['tags-path'];
|
||||||
}
|
}
|
||||||
|
if (array_key_exists('svn-cache-credentials', $this->repoConfig)) {
|
||||||
|
$this->cacheCredentials = (bool) $this->repoConfig['svn-cache-credentials'];
|
||||||
|
}
|
||||||
if (isset($this->repoConfig['package-path'])) {
|
if (isset($this->repoConfig['package-path'])) {
|
||||||
$this->packagePath = '/' . trim($this->repoConfig['package-path'], '/');
|
$this->packagePath = '/' . trim($this->repoConfig['package-path'], '/');
|
||||||
}
|
}
|
||||||
|
@ -307,6 +315,7 @@ class SvnDriver extends VcsDriver
|
||||||
{
|
{
|
||||||
if (null === $this->util) {
|
if (null === $this->util) {
|
||||||
$this->util = new SvnUtil($this->baseUrl, $this->io, $this->config, $this->process);
|
$this->util = new SvnUtil($this->baseUrl, $this->io, $this->config, $this->process);
|
||||||
|
$this->util->setCacheCredentials($this->cacheCredentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -147,6 +147,14 @@ class Svn
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param boolean $cacheCredentials
|
||||||
|
*/
|
||||||
|
public function setCacheCredentials($cacheCredentials)
|
||||||
|
{
|
||||||
|
$this->cacheCredentials = $cacheCredentials;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repositories requests credentials, let's put them in.
|
* Repositories requests credentials, let's put them in.
|
||||||
*
|
*
|
||||||
|
|
|
@ -72,6 +72,52 @@ class SvnTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals($this->getCmd(" --username 'foo' --password 'bar' "), $reflMethod->invoke($svn));
|
$this->assertEquals($this->getCmd(" --username 'foo' --password 'bar' "), $reflMethod->invoke($svn));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCredentialsFromConfigWithCacheCredentialsTrue()
|
||||||
|
{
|
||||||
|
$url = 'http://svn.apache.org';
|
||||||
|
|
||||||
|
$config = new Config();
|
||||||
|
$config->merge(
|
||||||
|
array(
|
||||||
|
'config' => array(
|
||||||
|
'http-basic' => array(
|
||||||
|
'svn.apache.org' => array('username' => 'foo', 'password' => 'bar')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$svn = new Svn($url, new NullIO, $config);
|
||||||
|
$svn->setCacheCredentials(true);
|
||||||
|
$reflMethod = new \ReflectionMethod('Composer\\Util\\Svn', 'getCredentialString');
|
||||||
|
$reflMethod->setAccessible(true);
|
||||||
|
|
||||||
|
$this->assertEquals($this->getCmd(" --username 'foo' --password 'bar' "), $reflMethod->invoke($svn));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCredentialsFromConfigWithCacheCredentialsFalse()
|
||||||
|
{
|
||||||
|
$url = 'http://svn.apache.org';
|
||||||
|
|
||||||
|
$config = new Config();
|
||||||
|
$config->merge(
|
||||||
|
array(
|
||||||
|
'config' => array(
|
||||||
|
'http-basic' => array(
|
||||||
|
'svn.apache.org' => array('username' => 'foo', 'password' => 'bar')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$svn = new Svn($url, new NullIO, $config);
|
||||||
|
$svn->setCacheCredentials(false);
|
||||||
|
$reflMethod = new \ReflectionMethod('Composer\\Util\\Svn', 'getCredentialString');
|
||||||
|
$reflMethod->setAccessible(true);
|
||||||
|
|
||||||
|
$this->assertEquals($this->getCmd(" --no-auth-cache --username 'foo' --password 'bar' "), $reflMethod->invoke($svn));
|
||||||
|
}
|
||||||
|
|
||||||
private function getCmd($cmd)
|
private function getCmd($cmd)
|
||||||
{
|
{
|
||||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||||
|
|
Loading…
Reference in New Issue