1
0
Fork 0

Fix compatibility with PHP 5.3

pull/3765/head
Jerome TAMARELLE 2015-11-13 16:49:14 +01:00
parent 6ec9f5ff02
commit 211d4632bb
3 changed files with 11 additions and 14 deletions

View File

@ -82,7 +82,7 @@ class GitLab
$this->io->writeError(sprintf('A token will be created and stored in "%s", your password will never be stored', $this->config->getAuthConfigSource()->getName())); $this->io->writeError(sprintf('A token will be created and stored in "%s", your password will never be stored', $this->config->getAuthConfigSource()->getName()));
$this->io->writeError('To revoke access to this token you can visit ' . $this->config->get('gitlab-domains')[0] . '/profile/applications'); $this->io->writeError('To revoke access to this token you can visit ' . $originUrl . '/profile/applications');
$attemptCounter = 0; $attemptCounter = 0;
@ -100,8 +100,8 @@ class GitLab
$this->io->writeError('Maximum number of login attempts exceeded. Please try again later.'); $this->io->writeError('Maximum number of login attempts exceeded. Please try again later.');
} }
$this->io->writeError('You can also manually create a personal token at ' . $this->config->get('gitlab-domains')[0] . '/profile/applications'); $this->io->writeError('You can also manually create a personal token at ' . $originUrl . '/profile/applications');
$this->io->writeError('Add it using "composer config gitlab-oauth.' . $this->config->get('gitlab-domains')[0] . ' <token>"'); $this->io->writeError('Add it using "composer config gitlab-oauth.' . $originUrl . ' <token>"');
continue; continue;
} }

View File

@ -363,7 +363,7 @@ class RemoteFilesystem
throw new TransportException('Could not authenticate against '.$this->originUrl, 401); throw new TransportException('Could not authenticate against '.$this->originUrl, 401);
} }
} elseif ($this->config && in_array($this->originUrl, $this->config->get('gitlab-domains'), true)) { } elseif ($this->config && in_array($this->originUrl, $this->config->get('gitlab-domains'), true)) {
$message = "\n".'Could not fetch '.$this->fileUrl.', enter your ' . $this->config->get('gitlab-domains')[0] . ' credentials ' .($httpStatus === 401 ? 'to access private repos' : 'to go over the API rate limit'); $message = "\n".'Could not fetch '.$this->fileUrl.', enter your ' . $this->originUrl . ' credentials ' .($httpStatus === 401 ? 'to access private repos' : 'to go over the API rate limit');
$gitLabUtil = new GitLab($this->io, $this->config, null); $gitLabUtil = new GitLab($this->io, $this->config, null);
if (!$gitLabUtil->authorizeOAuth($this->originUrl) if (!$gitLabUtil->authorizeOAuth($this->originUrl)
&& (!$this->io->isInteractive() || !$gitLabUtil->authorizeOAuthInteractively($this->originUrl, $message)) && (!$this->io->isInteractive() || !$gitLabUtil->authorizeOAuthInteractively($this->originUrl, $message))
@ -432,7 +432,7 @@ class RemoteFilesystem
$auth = $this->io->getAuthentication($originUrl); $auth = $this->io->getAuthentication($originUrl);
if ('github.com' === $originUrl && 'x-oauth-basic' === $auth['password']) { if ('github.com' === $originUrl && 'x-oauth-basic' === $auth['password']) {
$options['github-token'] = $auth['username']; $options['github-token'] = $auth['username'];
} elseif ($originUrl === $this->config->get('gitlab-domains')[0]) { } elseif ($this->config && in_array($originUrl, $this->config->get('gitlab-domains'), true)) {
if($auth['password'] === 'oauth2') { if($auth['password'] === 'oauth2') {
$headers[] = 'Authorization: Bearer '.$auth['username']; $headers[] = 'Authorization: Bearer '.$auth['username'];
} }
@ -449,9 +449,6 @@ class RemoteFilesystem
$options['http']['header'][] = $header; $options['http']['header'][] = $header;
} }
if($this->config && $this->config->get('gitlab-domains') && $originUrl == $this->config->get('gitlab-domains')[0]) {
$options['retry-auth-failure'] = false;
}
return $options; return $options;
} }
} }