1
0
Fork 0

Fix retry authentification on gitlab oauth

pull/3765/head
Jerome TAMARELLE 2015-11-13 18:32:00 +01:00
parent 211d4632bb
commit db056b8383
2 changed files with 11 additions and 23 deletions

View File

@ -51,7 +51,7 @@ class GitLab
*/ */
public function authorizeOAuth($originUrl) public function authorizeOAuth($originUrl)
{ {
if (!in_array($originUrl, $this->config->get('gitlab-domains'))) { if (!in_array($originUrl, $this->config->get('gitlab-domains'), true)) {
return false; return false;
} }
@ -122,37 +122,25 @@ class GitLab
private function createToken($originUrl) private function createToken($originUrl)
{ {
if (!$this->io->hasAuthentication($originUrl)) { $username = $this->io->ask('Username: ');
$username = $this->io->ask('Username: '); $password = $this->io->askAndHideAnswer('Password: ');
$password = $this->io->askAndHideAnswer('Password: ');
$this->io->setAuthentication($originUrl, $username, $password);
}
$headers = array('Content-Type: application/x-www-form-urlencoded'); $headers = array('Content-Type: application/x-www-form-urlencoded');
$note = 'Composer';
if ($this->config->get('GitLab-expose-hostname') === true && 0 === $this->process->execute('hostname', $output)) {
$note .= ' on ' . trim($output);
}
$note .= ' [' . date('YmdHis') . ']';
$apiUrl = $originUrl ; $apiUrl = $originUrl ;
$data = http_build_query( $data = http_build_query(array(
array( 'username' => $username,
'username' => $username, 'password' => $password,
'password' => $password, 'grant_type' => 'password',
'grant_type' => 'password', ));
)
);
$options = array( $options = array(
'retry-auth-failure' => false, 'retry-auth-failure' => false,
'http' => array( 'http' => array(
'method' => 'POST', 'method' => 'POST',
'header' => $headers, 'header' => $headers,
'content' => $data 'content' => $data
)); ),
);
$json = $this->remoteFilesystem->getContents($originUrl, 'http://'. $apiUrl . '/oauth/token', false, $options); $json = $this->remoteFilesystem->getContents($originUrl, 'http://'. $apiUrl . '/oauth/token', false, $options);