From 2cb07dd2fe8f03b52f742ffd34c83342d041160e Mon Sep 17 00:00:00 2001 From: Wes Mason Date: Sun, 21 Oct 2012 01:06:56 +0100 Subject: [PATCH 1/3] Allow use of Github OAuth2 token stored in git config --- src/Composer/Repository/Vcs/GitHubDriver.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index b31326deb..af2acd15d 100755 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -350,6 +350,15 @@ class GitHubDriver extends VcsDriver protected function authorizeOAuth() { + // If available use token from git config + exec('git config github.accesstoken', $output, $returnCode); + if ($returnCode === 0 && !empty($output[0])) + { + $this->io->write('Using Github OAuth token stored in git config (github.accesstoken)'); + $this->io->setAuthorization($this->originUrl, $output[0], 'x-oauth-basic'); + return; + } + $attemptCounter = 0; $this->io->write('The credentials will be swapped for an OAuth token stored in '.$this->config->get('home').'/config.json, your password will not be stored'); From 1442c1e026dd5ed70ae9c3abf8dd423dc3f19f4f Mon Sep 17 00:00:00 2001 From: Wes Mason Date: Sun, 21 Oct 2012 10:02:33 +0100 Subject: [PATCH 2/3] Damnable tabs! --- src/Composer/Repository/Vcs/GitHubDriver.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index af2acd15d..86d6ef281 100755 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -350,14 +350,14 @@ class GitHubDriver extends VcsDriver protected function authorizeOAuth() { - // If available use token from git config - exec('git config github.accesstoken', $output, $returnCode); - if ($returnCode === 0 && !empty($output[0])) - { - $this->io->write('Using Github OAuth token stored in git config (github.accesstoken)'); - $this->io->setAuthorization($this->originUrl, $output[0], 'x-oauth-basic'); - return; - } + // If available use token from git config + exec('git config github.accesstoken', $output, $returnCode); + if ($returnCode === 0 && !empty($output[0])) + { + $this->io->write('Using Github OAuth token stored in git config (github.accesstoken)'); + $this->io->setAuthorization($this->originUrl, $output[0], 'x-oauth-basic'); + return; + } $attemptCounter = 0; From 5fb040327604d313af14d802c54fb35225840edc Mon Sep 17 00:00:00 2001 From: Wes Mason Date: Sun, 21 Oct 2012 10:05:56 +0100 Subject: [PATCH 3/3] Use process executor instead of exec to run git config --- src/Composer/Repository/Vcs/GitHubDriver.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index 86d6ef281..df8777d05 100755 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -351,9 +351,7 @@ class GitHubDriver extends VcsDriver protected function authorizeOAuth() { // If available use token from git config - exec('git config github.accesstoken', $output, $returnCode); - if ($returnCode === 0 && !empty($output[0])) - { + if (0 === $this->process->execute('git config github.accesstoken', $output)) { $this->io->write('Using Github OAuth token stored in git config (github.accesstoken)'); $this->io->setAuthorization($this->originUrl, $output[0], 'x-oauth-basic'); return;