update
This commit is contained in:
100
modules/pshowsso/vendor/league/oauth2-github/src/Provider/Github.php
vendored
Normal file
100
modules/pshowsso/vendor/league/oauth2-github/src/Provider/Github.php
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace Pshowsso\Scope68f5e85e9608b\League\OAuth2\Client\Provider;
|
||||
|
||||
use Pshowsso\Scope68f5e85e9608b\League\OAuth2\Client\Provider\Exception\GithubIdentityProviderException;
|
||||
use Pshowsso\Scope68f5e85e9608b\League\OAuth2\Client\Token\AccessToken;
|
||||
use Pshowsso\Scope68f5e85e9608b\League\OAuth2\Client\Tool\BearerAuthorizationTrait;
|
||||
use Pshowsso\Scope68f5e85e9608b\Psr\Http\Message\ResponseInterface;
|
||||
class Github extends AbstractProvider
|
||||
{
|
||||
use BearerAuthorizationTrait;
|
||||
/**
|
||||
* Domain
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $domain = 'https://github.com';
|
||||
/**
|
||||
* Api domain
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $apiDomain = 'https://api.github.com';
|
||||
/**
|
||||
* Get authorization url to begin OAuth flow
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBaseAuthorizationUrl()
|
||||
{
|
||||
return $this->domain . '/login/oauth/authorize';
|
||||
}
|
||||
/**
|
||||
* Get access token url to retrieve token
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBaseAccessTokenUrl(array $params)
|
||||
{
|
||||
return $this->domain . '/login/oauth/access_token';
|
||||
}
|
||||
/**
|
||||
* Get provider url to fetch user details
|
||||
*
|
||||
* @param AccessToken $token
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceOwnerDetailsUrl(AccessToken $token)
|
||||
{
|
||||
if ($this->domain === 'https://github.com') {
|
||||
return $this->apiDomain . '/user';
|
||||
}
|
||||
return $this->domain . '/api/v3/user';
|
||||
}
|
||||
/**
|
||||
* Get the default scopes used by this provider.
|
||||
*
|
||||
* This should not be a complete list of all scopes, but the minimum
|
||||
* required for the provider user interface!
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getDefaultScopes()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
/**
|
||||
* Check a provider response for errors.
|
||||
*
|
||||
* @link https://developer.github.com/v3/#client-errors
|
||||
* @link https://developer.github.com/v3/oauth/#common-errors-for-the-access-token-request
|
||||
* @throws IdentityProviderException
|
||||
* @param ResponseInterface $response
|
||||
* @param string $data Parsed response data
|
||||
* @return void
|
||||
*/
|
||||
protected function checkResponse(ResponseInterface $response, $data)
|
||||
{
|
||||
if ($response->getStatusCode() >= 400) {
|
||||
throw GithubIdentityProviderException::clientException($response, $data);
|
||||
} elseif (isset($data['error'])) {
|
||||
throw GithubIdentityProviderException::oauthException($response, $data);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Generate a user object from a successful user details request.
|
||||
*
|
||||
* @param array $response
|
||||
* @param AccessToken $token
|
||||
* @return League\OAuth2\Client\Provider\ResourceOwnerInterface
|
||||
*/
|
||||
protected function createResourceOwner(array $response, AccessToken $token)
|
||||
{
|
||||
$user = new GithubResourceOwner($response);
|
||||
return $user->setDomain($this->domain);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user