Исправления безопасности и надёжности: установщик при сбое базы, права в API, нельзя выдать больше своего, пустой fillable, SSRF, очередь и расписание, роль при регистрации
This commit is contained in:
1 parent
6a550fef47
commit
ce446d071c
59 files changed
+1523
-114
No files matched your search
@@ -51,6 +51,8 @@ final class User extends Model
|
||||
*/
|
||||
private ?array $permissionsCache = null;
|
||||
|
||||
private ?bool $superuserCache = null;
|
||||
|
||||
public function role(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Role::class, 'role_id');
|
||||
@@ -71,6 +73,21 @@ final class User extends Model
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
/**
|
||||
* Со встроенной ролью администратора: у него всё, включая права, которых
|
||||
* ещё нет в реестре на момент, когда его права посчитали.
|
||||
*/
|
||||
public function isSuperuser(): bool
|
||||
{
|
||||
if ($this->superuserCache !== null) {
|
||||
return $this->superuserCache;
|
||||
}
|
||||
|
||||
$role = Role::find((int) $this->raw('role_id'));
|
||||
|
||||
return $this->superuserCache = $role !== null && $role->isSystem();
|
||||
}
|
||||
|
||||
public function permissions(): array
|
||||
{
|
||||
if ($this->permissionsCache !== null) {
|
||||
|
||||
Reference in new issue
Block a user