1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-10 09:02:59 +00:00

Handle envvar auth credentials as a JSON blob

As well as move the handling to a proper place
This commit is contained in:
Oliver Vartiainen 2016-01-19 20:34:04 +02:00
parent aaee6dc0b0
commit b39b113fc3
2 changed files with 13 additions and 9 deletions

View file

@ -60,6 +60,19 @@ abstract class BaseIO implements IOInterface
*/
public function loadConfiguration(Config $config)
{
// Use COMPOSER_AUTH environment variable if set
if ($envvar_data = getenv('COMPOSER_AUTH')) {
$auth_data = json_decode($envvar_data);
if (is_null($auth_data)) {
throw new \UnexpectedValueException('COMPOSER_AUTH environment variable is malformed');
}
foreach ($auth_data as $domain => $credentials) {
$this->setAuthentication($domain, $credentials->username, $credentials->password);
}
}
// reload oauth token from config if available
if ($tokens = $config->get('github-oauth')) {
foreach ($tokens as $domain => $token) {