mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-03 04:45:44 -05:00
Improve key handling
This commit is contained in:
@@ -8,6 +8,7 @@ use Pterodactyl\Models\Server;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Pterodactyl\Facades\Activity;
|
||||
use Pterodactyl\Models\Permission;
|
||||
use Pterodactyl\Models\UserSSHKey;
|
||||
use phpseclib3\Crypt\PublicKeyLoader;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use phpseclib3\Exception\NoKeyLoadedException;
|
||||
@@ -55,10 +56,14 @@ class SftpAuthenticationController extends Controller
|
||||
}
|
||||
} else {
|
||||
$key = null;
|
||||
try {
|
||||
$key = PublicKeyLoader::loadPublicKey(trim($request->input('password')));
|
||||
} catch (NoKeyLoadedException) {
|
||||
// do nothing
|
||||
$publicKey = trim($request->input('password'));
|
||||
|
||||
if (UserSSHKey::isSupportedPublicKeyMaterial($publicKey)) {
|
||||
try {
|
||||
$key = PublicKeyLoader::loadPublicKey($publicKey);
|
||||
} catch (NoKeyLoadedException) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
if (!$key || !$user->sshKeys()->where('fingerprint', $key->getFingerprint('sha256'))->exists()) {
|
||||
|
||||
Reference in New Issue
Block a user