feat(ssh-keys): add ssh key endpoints and ui components

This commit is contained in:
Matthew Penner 2021-07-17 15:45:46 -06:00
parent 9d64c6751b
commit f9114e2de0
17 changed files with 375 additions and 7 deletions

View file

@ -45,7 +45,7 @@ class AuditLog extends Model
/**
* @var string[]
*/
public static $validationRules = [
public static array $validationRules = [
'uuid' => 'required|uuid',
'action' => 'required|string|max:191',
'subaction' => 'nullable|string|max:191',

View file

@ -64,7 +64,7 @@ class DatabaseHost extends Model
*
* @var array
*/
public static $validationRules = [
public static array $validationRules = [
'name' => 'required|string|max:191',
'host' => 'required|string',
'port' => 'required|numeric|between:1,65535',

View file

@ -70,7 +70,7 @@ class EggVariable extends Model
/**
* @var array
*/
public static $validationRules = [
public static array $validationRules = [
'egg_id' => 'exists:eggs,id',
'name' => 'required|string|between:1,191',
'description' => 'string',

View file

@ -40,6 +40,7 @@ use Pterodactyl\Notifications\SendPasswordReset as ResetPasswordNotification;
* @property \Pterodactyl\Models\AdminRole $adminRole
* @property \Pterodactyl\Models\ApiKey[]|\Illuminate\Database\Eloquent\Collection $apiKeys
* @property \Pterodactyl\Models\Server[]|\Illuminate\Database\Eloquent\Collection $servers
* @property \Pterodactyl\Models\UserSSHKey|\Illuminate\Database\Eloquent\Collection $sshKeys
* @property \Pterodactyl\Models\RecoveryToken[]|\Illuminate\Database\Eloquent\Collection $recoveryTokens
* @property \LaravelWebauthn\Models\WebauthnKey[]|\Illuminate\Database\Eloquent\Collection $webauthnKeys
*/
@ -247,6 +248,11 @@ class User extends Model implements
return $this->hasMany(Server::class, 'owner_id');
}
public function sshKeys(): HasMany
{
return $this->hasMany(UserSSHKey::class);
}
public function recoveryTokens(): HasMany
{
return $this->hasMany(RecoveryToken::class);

View file

@ -2,15 +2,20 @@
namespace Pterodactyl\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* @property int $id
* @property int $user_id
* @property string $name
* @property string $public_key
* @property \Carbon\CarbonImmutable $created_at
* @property \Pterodactyl\Models\User $user
*/
class UserSSHKey extends Model
{
const UPDATED_AT = null;
protected $table = 'user_ssh_keys';
protected bool $immutableDates = true;
@ -23,4 +28,9 @@ class UserSSHKey extends Model
'name' => 'required|string',
'public_key' => 'required|string',
];
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}