mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 09:26:06 +00:00
Added KnownTranslationKeys (generated) and start using it
This commit is contained in:
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\auth;
|
||||
use FG\ASN1\Exception\ParserException;
|
||||
use Mdanter\Ecc\Crypto\Key\PublicKeyInterface;
|
||||
use Mdanter\Ecc\Serializer\PublicKey\DerPublicKeySerializer;
|
||||
use pocketmine\lang\KnownTranslationKeys;
|
||||
use pocketmine\network\mcpe\JwtException;
|
||||
use pocketmine\network\mcpe\JwtUtils;
|
||||
use pocketmine\network\mcpe\protocol\types\login\JwtChainLinkBody;
|
||||
@ -133,14 +134,14 @@ class ProcessLoginTask extends AsyncTask{
|
||||
|
||||
if($currentPublicKey === null){
|
||||
if(!$first){
|
||||
throw new VerifyLoginException("%pocketmine.disconnect.invalidSession.missingKey");
|
||||
throw new VerifyLoginException("%" . KnownTranslationKeys::POCKETMINE_DISCONNECT_INVALIDSESSION_MISSINGKEY);
|
||||
}
|
||||
|
||||
//First link, check that it is self-signed
|
||||
$currentPublicKey = $headers->x5u;
|
||||
}elseif($headers->x5u !== $currentPublicKey){
|
||||
//Fast path: if the header key doesn't match what we expected, the signature isn't going to validate anyway
|
||||
throw new VerifyLoginException("%pocketmine.disconnect.invalidSession.badSignature");
|
||||
throw new VerifyLoginException("%" . KnownTranslationKeys::POCKETMINE_DISCONNECT_INVALIDSESSION_BADSIGNATURE);
|
||||
}
|
||||
|
||||
$derPublicKeySerializer = new DerPublicKeySerializer();
|
||||
@ -156,7 +157,7 @@ class ProcessLoginTask extends AsyncTask{
|
||||
|
||||
try{
|
||||
if(!JwtUtils::verify($jwt, $signingKey)){
|
||||
throw new VerifyLoginException("%pocketmine.disconnect.invalidSession.badSignature");
|
||||
throw new VerifyLoginException("%" . KnownTranslationKeys::POCKETMINE_DISCONNECT_INVALIDSESSION_BADSIGNATURE);
|
||||
}
|
||||
}catch(JwtException $e){
|
||||
throw new VerifyLoginException($e->getMessage(), 0, $e);
|
||||
@ -180,11 +181,11 @@ class ProcessLoginTask extends AsyncTask{
|
||||
|
||||
$time = time();
|
||||
if(isset($claims->nbf) and $claims->nbf > $time + self::CLOCK_DRIFT_MAX){
|
||||
throw new VerifyLoginException("%pocketmine.disconnect.invalidSession.tooEarly");
|
||||
throw new VerifyLoginException("%" . KnownTranslationKeys::POCKETMINE_DISCONNECT_INVALIDSESSION_TOOEARLY);
|
||||
}
|
||||
|
||||
if(isset($claims->exp) and $claims->exp < $time - self::CLOCK_DRIFT_MAX){
|
||||
throw new VerifyLoginException("%pocketmine.disconnect.invalidSession.tooLate");
|
||||
throw new VerifyLoginException("%" . KnownTranslationKeys::POCKETMINE_DISCONNECT_INVALIDSESSION_TOOLATE);
|
||||
}
|
||||
|
||||
$currentPublicKey = $claims->identityPublicKey ?? null; //if there are further links, the next link should be signed with this
|
||||
|
Reference in New Issue
Block a user