Skip to content

Commit

Permalink
Merge pull request #211 from andytson-inviqa/feature/github-authoriza…
Browse files Browse the repository at this point in the history
…tion-header

Use authorization: token header for Github authentication
  • Loading branch information
hirak authored Feb 16, 2020
2 parents a382b93 + fbc5e00 commit 53d20eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/BaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected function setupAuthentication(IO\IOInterface $io, $useRedirector, array

// is github
if (in_array($authKey, $githubDomains) && 'x-oauth-basic' === $auth['password']) {
$this->addParam('access_token', $auth['username']);
$this->addHeader('authorization', 'token ' . $auth['username']);
$this->user = $this->pass = null;
return;
}
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/CopyRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,15 @@ public function testGitHubRedirector()

// user:pass -> query
$req = new CopyRequest($example, $tmpfile, false, $this->iop->reveal(), $this->configp->reveal());
$this->assertEquals("$example&access_token=at", $req->getURL());
$this->assertEquals($example, $req->getURL());
$opts = $req->getCurlOptions();
$this->assertContains('Authorization: token at', $opts[CURLOPT_HTTPHEADER]);

// api.github.com -> codeload.github.com
$req = new CopyRequest($example, $tmpfile, true, $this->iop->reveal(), $this->configp->reveal());
$this->assertEquals('https://codeload.github.com/vendor/name/legacy.zip/aaaa?a=b&access_token=at', $req->getURL());
$this->assertEquals('https://codeload.github.com/vendor/name/legacy.zip/aaaa?a=b', $req->getURL());
$opts = $req->getCurlOptions();
$this->assertContains('Authorization: token at', $opts[CURLOPT_HTTPHEADER]);
}

public function testGitLab()
Expand Down

0 comments on commit 53d20eb

Please sign in to comment.