1
0
Fork 0

Implement most desirable Authorization method.

As per https://developer.atlassian.com/bitbucket/api/2/reference/meta/authentication#make-requests
adding the OAuth access token in the Authorization header is desired above adding it to the URL.
pull/6094/head
Stefan Grootscholten 2016-12-27 16:29:39 +01:00
parent 512750a20e
commit b3b05949bb
1 changed files with 3 additions and 9 deletions

View File

@ -245,14 +245,6 @@ class RemoteFilesystem
unset($options['gitlab-token']); unset($options['gitlab-token']);
} }
if (isset($options['bitbucket-token'])) {
// skip using the token for BitBucket downloads as these are not working with auth
if (!$this->isPublicBitBucketDownload($origFileUrl)) {
$fileUrl .= (false === strpos($fileUrl,'?') ? '?' : '&') . 'access_token=' . $options['bitbucket-token'];
}
unset($options['bitbucket-token']);
}
if (isset($options['http'])) { if (isset($options['http'])) {
$options['http']['ignore_errors'] = true; $options['http']['ignore_errors'] = true;
} }
@ -730,7 +722,9 @@ class RemoteFilesystem
} elseif ('bitbucket.org' === $originUrl } elseif ('bitbucket.org' === $originUrl
&& $this->fileUrl !== Bitbucket::OAUTH2_ACCESS_TOKEN_URL && 'x-token-auth' === $auth['username'] && $this->fileUrl !== Bitbucket::OAUTH2_ACCESS_TOKEN_URL && 'x-token-auth' === $auth['username']
) { ) {
$options['bitbucket-token'] = $auth['password']; if (!$this->isPublicBitBucketDownload($this->fileUrl)) {
$headers[] = 'Authorization: Bearer ' . $auth['password'];
}
} else { } else {
$authStr = base64_encode($auth['username'] . ':' . $auth['password']); $authStr = base64_encode($auth['username'] . ':' . $auth['password']);
$headers[] = 'Authorization: Basic '.$authStr; $headers[] = 'Authorization: Basic '.$authStr;