Просмотр исходного кода

Fixed OAuth credentials issue for subsequent clone requests.

Paul.Wenke 9 лет назад
Родитель
Сommit
9ddf8c4d55
1 измененных файлов с 7 добавлено и 3 удалено
  1. 7 3
      src/Composer/Util/Git.php

+ 7 - 3
src/Composer/Util/Git.php

@@ -114,7 +114,7 @@ class Git
                         return;
                     }
                 }
-            } elseif (preg_match('{^(?:https?|git)://'.self::getBitbucketDomainsRegex($this->config).'/(.*)\.git}', $url, $match)) { //bitbucket oauth
+            } elseif (preg_match('{^(?:https?|git)://'.self::getBitbucketDomainsRegex($this->config).'/(.*)}', $url, $match)) { //bitbucket oauth
                 $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process);
 
                 if (!$this->io->hasAuthentication($match[1])) {
@@ -127,8 +127,12 @@ class Git
                     }
                 } else { //We're authenticating with a locally stored consumer.
                     $auth = $this->io->getAuthentication($match[1]);
-                    $token = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']);
-                    $this->io->setAuthentication($match[1], 'x-token-auth', $token['access_token']);
+
+                    //We already have an access_token from a previous request.
+                    if($auth['username'] !== 'x-token-auth') {
+                        $token = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']);
+                        $this->io->setAuthentication($match[1], 'x-token-auth', $token['access_token']);
+                    }
                 }
 
                 if ($this->io->hasAuthentication($match[1])) {