Have the panel handle all of the authorization for both public key and password based attempts
This commit is contained in:
parent
e856daee19
commit
412ac5ef39
2 changed files with 4 additions and 8 deletions
|
@ -28,7 +28,8 @@ abstract class SftpAuthenticationController extends Controller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authenticate a set of credentials and return the associated server details
|
* Authenticate a set of credentials and return the associated server details
|
||||||
* for a SFTP connection on the daemon.
|
* for a SFTP connection on the daemon. This supports both public key and password
|
||||||
|
* based credentials.
|
||||||
*/
|
*/
|
||||||
public function __invoke(SftpAuthenticationFormRequest $request): JsonResponse
|
public function __invoke(SftpAuthenticationFormRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
@ -44,9 +45,7 @@ abstract class SftpAuthenticationController extends Controller
|
||||||
$this->reject($request);
|
$this->reject($request);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Start blocking requests when the user has no public keys in the first place —
|
if (!$user->sshKeys()->where('public_key', $request->input('password'))->exists()) {
|
||||||
// don't let the user spam this endpoint.
|
|
||||||
if ($user->sshKeys->isEmpty()) {
|
|
||||||
$this->reject($request);
|
$this->reject($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace Pterodactyl\Http\Requests\Api\Remote;
|
namespace Pterodactyl\Http\Requests\Api\Remote;
|
||||||
|
|
||||||
use Illuminate\Validation\Rule;
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
class SftpAuthenticationFormRequest extends FormRequest
|
class SftpAuthenticationFormRequest extends FormRequest
|
||||||
|
@ -27,9 +26,7 @@ class SftpAuthenticationFormRequest extends FormRequest
|
||||||
return [
|
return [
|
||||||
'type' => ['nullable', 'in:password,public_key'],
|
'type' => ['nullable', 'in:password,public_key'],
|
||||||
'username' => ['required', 'string'],
|
'username' => ['required', 'string'],
|
||||||
'password' => [
|
'password' => ['required', 'string'],
|
||||||
Rule::when(fn () => $this->input('type') !== 'public_key', ['required', 'string'], ['nullable']),
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue