Commit
…local auth file support, add storage to auth.json, add store-auths config option, refs #1862
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,12 +106,20 @@ public static function createConfig() | |
// add dirs to the config | ||
$config->merge(array('config' => array('home' => $home, 'cache-dir' => $cacheDir))); | ||
|
||
// load global config | ||
$file = new JsonFile($home.'/config.json'); | ||
if ($file->exists()) { | ||
$config->merge($file->read()); | ||
} | ||
$config->setConfigSource(new JsonConfigSource($file)); | ||
|
||
// load global auth file | ||
$file = new JsonFile($config->get('home').'/auth.json'); | ||
if ($file->exists()) { | ||
$config->merge(array('config' => $file->read())); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
$config->setAuthConfigSource(new JsonConfigSource($file, true)); | ||
|
||
// move old cache dirs to the new locations | ||
$legacyPaths = array( | ||
'cache-repo-dir' => array('/cache' => '/http*', '/cache.svn' => '/*', '/cache.github' => '/*'), | ||
|
@@ -147,26 +155,6 @@ public static function createConfig() | |
return $config; | ||
} | ||
|
||
/** | ||
* @return Config | ||
*/ | ||
protected static function createAuthConfig() | ||
{ | ||
$home = self::getHomeDir(); | ||
|
||
$config = new Config(); | ||
// add dirs to the config | ||
$config->merge(array('config' => array('home' => $home))); | ||
|
||
$file = new JsonFile($home.'/auth.json'); | ||
if ($file->exists()) { | ||
$config->merge($file->read()); | ||
} | ||
$config->setConfigSource(new JsonConfigSource($file)); | ||
|
||
return $config; | ||
} | ||
|
||
public static function getComposerFile() | ||
{ | ||
return trim(getenv('COMPOSER')) ?: './composer.json'; | ||
|
@@ -248,25 +236,20 @@ public function createComposer(IOInterface $io, $localConfig = null, $disablePlu | |
$localConfig = $file->read(); | ||
} | ||
|
||
// Configuration defaults | ||
// Load config and override with local config/auth config | ||
$config = static::createConfig(); | ||
$config->merge($localConfig); | ||
$io->loadConfiguration($config); | ||
|
||
// load separate auth config | ||
$authConfig = static::createAuthConfig(); | ||
if ($basicauth = $authConfig->get('basic-auth')) { | ||
foreach ($basicauth as $domain => $credentials) { | ||
if(!isset($credentials['username'])) { | ||
continue; | ||
} | ||
if(!isset($credentials['password'])) { | ||
$credentials['password'] = null; | ||
} | ||
$io->setAuthentication($domain, $credentials['username'], $credentials['password']); | ||
if (isset($composerFile)) { | ||
$localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json'); | ||
if ($localAuthFile->exists()) { | ||
$config->merge(array('config' => $localAuthFile->read())); | ||
This comment has been minimized.
Sorry, something went wrong.
staabm
Contributor
|
||
$config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true)); | ||
} | ||
} | ||
|
||
// load auth configs into the IO instance | ||
$io->loadConfiguration($config); | ||
|
||
$vendorDir = $config->get('vendor-dir'); | ||
$binDir = $config->get('bin-dir'); | ||
|
||
|
2 comments
on commit 90d1b6e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I guess config.json
won't be searched anymore for authentication? Only auth.json
will be searched.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically auth.json is merely merged into the base config, so if you have stuff in config.json it should still work
In verbose mode, it could be worth a line of debug-out that a global conf was read and from which location