updated EveOnlineOAuthProvider
This commit is contained in:
@@ -2,13 +2,21 @@
|
|||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use Laravel\Socialite\Two\ProviderInterface;
|
use Jose\Component\Core\JWKSet;
|
||||||
use Laravel\Socialite\Two\AbstractProvider;
|
use Jose\Easy\Load;
|
||||||
use Laravel\Socialite\Two\User;
|
//use Laravel\Socialite\Two\ProviderInterface;
|
||||||
//use Jose\Component\Core\JWKSet;
|
//use Laravel\Socialite\Two\AbstractProvider;
|
||||||
//use Jose\Easy\Load;
|
//use Laravel\Socialite\Two\User;
|
||||||
|
use SocialiteProviders\Manager\OAuth2\AbstractProvider;
|
||||||
|
use SocialiteProviders\Manager\OAuth2\User;
|
||||||
|
|
||||||
class EveOnlineOAuthProvider extends AbstractProvider implements ProviderInterface {
|
|
||||||
|
class EveOnlineOAuthProvider extends AbstractProvider {
|
||||||
|
/**
|
||||||
|
* The separating character for the request scopes
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $scopeSeparator = ' ';
|
protected $scopeSeparator = ' ';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,10 +26,6 @@ class EveOnlineOAuthProvider extends AbstractProvider implements ProviderInterfa
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getAuthUrl($state) {
|
protected function getAuthUrl($state) {
|
||||||
return $this->buildAuthUrlFromBase('https://login.eveonline.com/oauth/authorize', $state);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getAuthUrlNew($state) {
|
|
||||||
return $this->buildAuthUrlFromBase('https://login.eveonline.com/v2/oauth/authorize', $state);
|
return $this->buildAuthUrlFromBase('https://login.eveonline.com/v2/oauth/authorize', $state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,10 +35,6 @@ class EveOnlineOAuthProvider extends AbstractProvider implements ProviderInterfa
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getTokenUrl() {
|
protected function getTokenUrl() {
|
||||||
return 'https://login.eveonline.com/oauth/token';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getTokenUrlNew() {
|
|
||||||
return 'https://login.eveonline.com/v2/oauth/token';
|
return 'https://login.eveonline.com/v2/oauth/token';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,14 +44,8 @@ class EveOnlineOAuthProvider extends AbstractProvider implements ProviderInterfa
|
|||||||
* @param string $token
|
* @param string $token
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getUserByToken($token) {
|
protected function getUserByToken2($token) {
|
||||||
$reponse = $this->getHttpClient()->get('https://login.eveonline.com/oauth/verify', [
|
return $this->validateJwtToken($token);
|
||||||
'headers' => [
|
|
||||||
'Authorization' => 'Bearer ' . $token,
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
return json_decode($reponse->getBody()->getContents(), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,8 +62,8 @@ class EveOnlineOAuthProvider extends AbstractProvider implements ProviderInterfa
|
|||||||
'nickname' => $user['CharacterName'],
|
'nickname' => $user['CharacterName'],
|
||||||
'owner_hash' => $user['CharacterOwnerHash'],
|
'owner_hash' => $user['CharacterOwnerHash'],
|
||||||
'avatar' => 'https://image.eveonline.com/Character/' . $user['CharacterID'] . '_128.jpg',
|
'avatar' => 'https://image.eveonline.com/Character/' . $user['CharacterID'] . '_128.jpg',
|
||||||
//'token_type' => $user['TokenType'],
|
'token_type' => $user['TokenType'],
|
||||||
//'expires_on' => $user['ExpiresOn'],
|
'expires_on' => $user['ExpiresOn'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,13 +77,38 @@ class EveOnlineOAuthProvider extends AbstractProvider implements ProviderInterfa
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getJwkUri(): string {
|
||||||
|
$response = $this->getHttpClient()
|
||||||
|
->get('https://login.eveonline.com/.well-knonw/oauth-authorization-server');
|
||||||
|
|
||||||
|
$metadata = json_decode($response->getBody());
|
||||||
|
|
||||||
|
return $metadata->jwks_uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
* An array representing the JWK Key Sets
|
||||||
|
*/
|
||||||
|
private function getJwkSets(): array {
|
||||||
|
$jwk_uri = $this->getJwkUri();
|
||||||
|
|
||||||
|
$response = $this->getHttpClient()
|
||||||
|
->get($jwk_uri);
|
||||||
|
|
||||||
|
return json_decode($response->getBody(), true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $access_token
|
* @param string $access_token
|
||||||
* @return array
|
* @return array
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
private function validateJwtToken(string $access_token): array {
|
private function validateJwtToken(string $access_token): array {
|
||||||
$scopes = array();
|
$scopes = session()->pull('scopes', []);
|
||||||
|
|
||||||
// pulling JWK sets from CCP
|
// pulling JWK sets from CCP
|
||||||
$sets = $this->getJwkSets();
|
$sets = $this->getJwkSets();
|
||||||
|
|||||||
Reference in New Issue
Block a user