jwt token stuff
This commit is contained in:
@@ -84,7 +84,7 @@ class LoginController extends Controller
|
|||||||
public function handleProviderCallback() {
|
public function handleProviderCallback() {
|
||||||
//Get the sso user from the socialite driver
|
//Get the sso user from the socialite driver
|
||||||
$ssoUser = Socialite::driver('eveonline')->user();
|
$ssoUser = Socialite::driver('eveonline')->user();
|
||||||
dd($ssoUser);
|
|
||||||
if(Auth::check()) {
|
if(Auth::check()) {
|
||||||
//If a refresh token is present, then we are doing a scope callback
|
//If a refresh token is present, then we are doing a scope callback
|
||||||
//to update scopes for an access token
|
//to update scopes for an access token
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ namespace App\Providers;
|
|||||||
use Laravel\Socialite\Two\ProviderInterface;
|
use Laravel\Socialite\Two\ProviderInterface;
|
||||||
use Laravel\Socialite\Two\AbstractProvider;
|
use Laravel\Socialite\Two\AbstractProvider;
|
||||||
use Laravel\Socialite\Two\User;
|
use Laravel\Socialite\Two\User;
|
||||||
|
//use Jose\Component\Core\JWKSet;
|
||||||
|
//use Jose\Easy\Load;
|
||||||
|
|
||||||
class EveOnlineOAuthProvider extends AbstractProvider implements ProviderInterface {
|
class EveOnlineOAuthProvider extends AbstractProvider implements ProviderInterface {
|
||||||
protected $scopeSeparator = ' ';
|
protected $scopeSeparator = ' ';
|
||||||
@@ -16,6 +18,10 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,6 +31,10 @@ 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';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,8 +68,8 @@ class EveOnlineOAuthProvider extends AbstractProvider implements ProviderInterfa
|
|||||||
'nickname' => $user['CharacterName'],
|
'nickname' => $user['CharacterName'],
|
||||||
'character_owner_hash' => $user['CharacterOwnerHash'],
|
'character_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'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,6 +82,37 @@ class EveOnlineOAuthProvider extends AbstractProvider implements ProviderInterfa
|
|||||||
'grant_type' => 'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $access_token
|
||||||
|
* @return array
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
private function validateJwtToken(string $access_token): array {
|
||||||
|
$scopes = array();
|
||||||
|
|
||||||
|
// pulling JWK sets from CCP
|
||||||
|
$sets = $this->getJwkSets();
|
||||||
|
|
||||||
|
// loading JWK Sets Manager
|
||||||
|
$jwk_sets = JWKSet::createFromKeyData($sets);
|
||||||
|
|
||||||
|
// attempt to parse the JWT and collect payload
|
||||||
|
$jws = Load::jws($access_token)
|
||||||
|
->algs(['RS256', 'ES256', 'HS256'])
|
||||||
|
->exp()
|
||||||
|
->iss('login.eveonline.com')
|
||||||
|
->header('typ', new TypeChecker(['JWT'], true))
|
||||||
|
->claim('scp', new ScpChecker($scopes))
|
||||||
|
->claim('sub', new SubEveCharacterChecker())
|
||||||
|
->claim('azp', new AzpChecker(config('esi.eseye_client_id')))
|
||||||
|
->claim('name', new NameChecker())
|
||||||
|
->claim('owner', new OwnerChecker())
|
||||||
|
->keyset($jwk_sets)
|
||||||
|
->run();
|
||||||
|
|
||||||
|
return $jws->claims->all();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Reference in New Issue
Block a user