mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-10 02:13:44 +02:00
Change how API keys are validated (#771)
This commit is contained in:
@@ -19,6 +19,8 @@ class APIKey extends Model implements CleansAttributes, ValidableContract
|
||||
{
|
||||
use Eloquence, Validable;
|
||||
|
||||
const KEY_LENGTH = 32;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
@@ -26,13 +28,6 @@ class APIKey extends Model implements CleansAttributes, ValidableContract
|
||||
*/
|
||||
protected $table = 'api_keys';
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['secret'];
|
||||
|
||||
/**
|
||||
* Cast values to correct type.
|
||||
*
|
||||
@@ -57,8 +52,7 @@ class APIKey extends Model implements CleansAttributes, ValidableContract
|
||||
protected static $applicationRules = [
|
||||
'memo' => 'required',
|
||||
'user_id' => 'required',
|
||||
'secret' => 'required',
|
||||
'public' => 'required',
|
||||
'token' => 'required',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -68,8 +62,7 @@ class APIKey extends Model implements CleansAttributes, ValidableContract
|
||||
*/
|
||||
protected static $dataIntegrityRules = [
|
||||
'user_id' => 'exists:users,id',
|
||||
'public' => 'string|size:16',
|
||||
'secret' => 'string',
|
||||
'token' => 'string|size:32',
|
||||
'memo' => 'nullable|string|max:500',
|
||||
'allowed_ips' => 'nullable|json',
|
||||
'expires_at' => 'nullable|datetime',
|
||||
|
||||
Reference in New Issue
Block a user