1
0
Fork 0

Merge remote-tracking branch 'firoxer/envvar_auth'

pull/4840/head
Jordi Boggiano 2016-01-26 18:59:55 +00:00
commit e513f27674
1 changed files with 13 additions and 0 deletions

View File

@ -60,6 +60,19 @@ abstract class BaseIO implements IOInterface
*/ */
public function loadConfiguration(Config $config) 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 // reload oauth token from config if available
if ($tokens = $config->get('github-oauth')) { if ($tokens = $config->get('github-oauth')) {
foreach ($tokens as $domain => $token) { foreach ($tokens as $domain => $token) {