jwt token stuff

This commit is contained in:
2021-02-12 05:20:00 +09:00
parent cf1876e43f
commit 0a11a5d23d
2 changed files with 44 additions and 3 deletions

View File

@@ -84,7 +84,7 @@ class LoginController extends Controller
public function handleProviderCallback() {
//Get the sso user from the socialite driver
$ssoUser = Socialite::driver('eveonline')->user();
dd($ssoUser);
if(Auth::check()) {
//If a refresh token is present, then we are doing a scope callback
//to update scopes for an access token

View File

@@ -5,6 +5,8 @@ namespace App\Providers;
use Laravel\Socialite\Two\ProviderInterface;
use Laravel\Socialite\Two\AbstractProvider;
use Laravel\Socialite\Two\User;
//use Jose\Component\Core\JWKSet;
//use Jose\Easy\Load;
class EveOnlineOAuthProvider extends AbstractProvider implements ProviderInterface {
protected $scopeSeparator = ' ';
@@ -16,6 +18,10 @@ class EveOnlineOAuthProvider extends AbstractProvider implements ProviderInterfa
* @return string
*/
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);
}
@@ -25,6 +31,10 @@ class EveOnlineOAuthProvider extends AbstractProvider implements ProviderInterfa
* @return string
*/
protected function getTokenUrl() {
return 'https://login.eveonline.com/oauth/token';
}
protected function getTokenUrlNew() {
return 'https://login.eveonline.com/v2/oauth/token';
}
@@ -58,8 +68,8 @@ class EveOnlineOAuthProvider extends AbstractProvider implements ProviderInterfa
'nickname' => $user['CharacterName'],
'character_owner_hash' => $user['CharacterOwnerHash'],
'avatar' => 'https://image.eveonline.com/Character/' . $user['CharacterID'] . '_128.jpg',
'token_type' => $user['TokenType'],
'expires_on' => $user['ExpiresOn'],
//'token_type' => $user['TokenType'],
//'expires_on' => $user['ExpiresOn'],
]);
}
@@ -72,6 +82,37 @@ class EveOnlineOAuthProvider extends AbstractProvider implements ProviderInterfa
'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();
}
}
?>