1
0
Fork 0

Merge pull request #9156 from Ayesh/gitlab-repos

AuthHelper: Allow fall-through GitLab-specific HTTP headers for auth
pull/9161/head
Jordi Boggiano 2020-08-27 10:06:28 +02:00 committed by GitHub
commit 9e77514764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -205,7 +205,10 @@ class AuthHelper
$headers[] = 'Authorization: token '.$auth['username'];
$authenticationDisplayMessage = 'Using GitHub token authentication';
}
} elseif (in_array($origin, $this->config->get('gitlab-domains'), true)) {
} elseif (
in_array($origin, $this->config->get('gitlab-domains'), true)
&& in_array($auth['password'], array('oauth2', 'private-token', 'gitlab-ci-token'), true)
) {
if ($auth['password'] === 'oauth2') {
$headers[] = 'Authorization: Bearer '.$auth['username'];
$authenticationDisplayMessage = 'Using GitLab OAuth token authentication';

View File

@ -280,6 +280,14 @@ class AuthHelperTest extends TestCase
'password' => 'my_password'
)
),
array(
'https://gitlab.com',
'gitlab.com',
array(
'username' => 'my_username',
'password' => 'my_password'
)
),
);
}
@ -302,7 +310,7 @@ class AuthHelperTest extends TestCase
$this->config->expects($this->once())
->method('get')
->with('gitlab-domains')
->willReturn(array());
->willReturn(array($origin));
$this->io->expects($this->once())
->method('writeError')