Refactor code to use RemoteFilesystem facilities for header parsing, refs #5435
parent
f8c3ef4136
commit
1c4acf3583
|
@ -325,25 +325,18 @@ class GitHubDriver extends VcsDriver
|
||||||
return $this->attemptCloneFallback();
|
return $this->attemptCloneFallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
$scopes_issued = array();
|
$scopesIssued = array();
|
||||||
$scopes_needed = array();
|
$scopesNeeded = array();
|
||||||
if (!is_null($headers = $e->getHeaders())) {
|
if ($headers = $e->getHeaders()) {
|
||||||
// Check if X-OAuth-Scopes and X-Accepted-OAuth-Scopes should let us in...
|
if ($scopes = $this->remoteFilesystem->findHeaderValue($headers, 'X-OAuth-Scopes')) {
|
||||||
foreach ($headers as $header) {
|
$scopesIssued = explode(' ', $scopes);
|
||||||
$k = substr($header, 0, strpos($header, ":"));
|
}
|
||||||
$v = trim(substr($header, strpos($header, ":")+1));
|
if ($scopes = $this->remoteFilesystem->findHeaderValue($headers, 'X-Accepted-OAuth-Scopes')) {
|
||||||
switch ($k) {
|
$scopesNeeded = explode(' ', $scopes);
|
||||||
case 'X-OAuth-Scopes':
|
|
||||||
$scopes_issued = explode(" ", $v);
|
|
||||||
break;
|
|
||||||
case 'X-Accepted-OAuth-Scopes':
|
|
||||||
$scopes_needed = explode(" ", $v);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
$scopesFailed = array_diff($scopesNeeded, $scopesIssued);
|
||||||
$scopes_failed = array_diff($scopes_needed, $scopes_issued);
|
if (!$headers || count($scopesFailed)) {
|
||||||
if (is_null($headers) || count($scopes_failed)) {
|
|
||||||
$gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'Your GitHub credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
|
$gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'Your GitHub credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue