Revert "[yggdrasil-api] implement Mojang publickeys API (#193)"

This reverts commit a48965743d.
This commit is contained in:
Zephyr Lykos 2024-01-19 22:54:06 +08:00
parent addddec71c
commit ed46a1df2d
No known key found for this signature in database
GPG Key ID: D3E9D31E2F77F04D
5 changed files with 19 additions and 69 deletions

View File

@ -18,11 +18,6 @@ Route::prefix('authserver')
Route::post('invalidate', 'AuthController@invalidate');
});
Route::prefix('minecraftservices')
->group(function () {
Route::get('publickeys', 'ServicesController@getPublicKeys');
});
Route::prefix('sessionserver/session/minecraft')->group(function () {
Route::post('join', 'SessionController@joinServer');
Route::get('hasJoined', 'SessionController@hasJoinedServer');

View File

@ -10,7 +10,7 @@ use Exception;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Option;
use Yggdrasil\Utils\Key;
use Yggdrasil\Exceptions\IllegalArgumentException;
class ConfigController extends Controller
{
@ -77,7 +77,17 @@ class ConfigController extends Controller
$request->getHost(),
]))));
$privateKey = Key::getPrivateKey(config('ygg_private_key'));
$privateKey = openssl_pkey_get_private(option('ygg_private_key'));
if (!$privateKey) {
throw new IllegalArgumentException(trans('Yggdrasil::config.rsa.invalid'));
}
$keyData = openssl_pkey_get_details($privateKey);
if ($keyData['bits'] < 4096) {
throw new IllegalArgumentException(trans('Yggdrasil::config.rsa.length'));
}
$result = [
'meta' => [
@ -90,7 +100,7 @@ class ConfigController extends Controller
'feature.non_email_login' => true,
],
'skinDomains' => $skinDomains,
'signaturePublickey' => Key::getPublicKey($privateKey),
'signaturePublickey' => $keyData['key'],
];
if (!optional($pluginManager->get('disable-registration'))->isEnabled()) {

View File

@ -1,29 +0,0 @@
<?php
namespace Yggdrasil\Controllers;
use Illuminate\Routing\Controller;
use Yggdrasil\Utils\Key;
class ServicesController extends Controller
{
public function getPublicKeys()
{
$privateKey = Key::getPrivateKey(config('ygg_private_key'));
$result = [
'profilePropertyKeys' => [
[
'publicKey' => Key::getPublicKey($privateKey),
],
],
'playerCertificateKeys' => [
[
'pulicKey' => Key::getPublicKey($privateKey),
],
],
];
return json($result);
}
}

View File

@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Http;
use Log;
use Ramsey\Uuid\Uuid;
use Schema;
use Yggdrasil\Utils\Key;
use Yggdrasil\Exceptions\IllegalArgumentException;
class Profile
{
@ -46,7 +46,11 @@ class Profile
// 检查 RSA 私钥
if ($unsigned === false) {
$key = Key::getPrivateKey(config('ygg_private_key'));
$key = openssl_pkey_get_private(option('ygg_private_key'));
if (!$key) {
throw new IllegalArgumentException(trans('Yggdrasil::config.rsa.invalid'));
}
$textures['signatureRequired'] = true;
}

View File

@ -1,30 +0,0 @@
<?php
namespace Yggdrasil\Utils;
use Yggdrasil\Exceptions\IllegalArgumentException;
class Key
{
public static function getPrivateKey($key)
{
$privateKey = openssl_pkey_get_private(option('ygg_private_key'));
if (!$privateKey) {
throw new IllegalArgumentException(trans('Yggdrasil::config.rsa.invalid'));
}
return $privateKey;
}
public static function getPublicKey($key)
{
$keyData = openssl_pkey_get_details($key);
if ($keyData['bits'] < 4096) {
throw new IllegalArgumentException(trans('Yggdrasil::config.rsa.length'));
}
return $keyData['key'];
}
}