security: Rechteausweitung schließen & Admin-Panel feingranular gaten (K1, H1, H2, M8)
- users:manage/roles:manage auf allen User-/Rollen-Masken erzwungen; is_super_admin aus $fillable entfernt und nur per autorisiertem forceFill setzbar; zentraler Gate::before-Super-Admin-Kurzschluss (K1/M8). - Nicht-Super-Admins können Super-Admin-Konten nicht mehr bearbeiten (Fix#2); Impersonation mit Rangprüfung, keine Token-Erstellung während Impersonation (H1). - Destruktive/verwaltende Admin-Aktionen (CRM/Billing/Compliance/Struktur) hängen an neuen admin-only Permissions; Editor behält reine Content-Rechte (H2). - Kanonischer Permission-Katalog (App\Authorization\Permission) als Single Source of Truth für Seeder und Monitoring. Deployment: `php artisan db:seed --class=RolesAndPermissionsSeeder` auf allen Umgebungen ausführen (neue Permissions). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
299837d2ba
commit
40783192d0
34 changed files with 748 additions and 100 deletions
|
|
@ -20,7 +20,8 @@ class UserImpersonation
|
|||
return $this->canInitiate($admin)
|
||||
&& ! $admin->is($target)
|
||||
&& ! $this->isActive()
|
||||
&& $this->canBeImpersonated($target);
|
||||
&& $this->canBeImpersonated($target)
|
||||
&& $this->mayImpersonateRank($admin, $target);
|
||||
}
|
||||
|
||||
public function canBeImpersonated(User $target): bool
|
||||
|
|
@ -28,6 +29,16 @@ class UserImpersonation
|
|||
return $target->canAccessCustomer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Rang-Schutz: Ein Super-Admin darf nur von einem Super-Admin im Panel
|
||||
* angemeldet werden. Verhindert, dass ein Admin (users:manage) das mächtigere
|
||||
* Super-Admin-Konto übernimmt und in dessen Namen z. B. API-Token erzeugt.
|
||||
*/
|
||||
public function mayImpersonateRank(User $admin, User $target): bool
|
||||
{
|
||||
return $admin->is_super_admin || ! $target->is_super_admin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws AuthorizationException
|
||||
*/
|
||||
|
|
@ -49,6 +60,10 @@ class UserImpersonation
|
|||
throw new AuthorizationException(__('Dieser Benutzer kann nicht im Panel angemeldet werden.'));
|
||||
}
|
||||
|
||||
if (! $this->mayImpersonateRank($admin, $target)) {
|
||||
throw new AuthorizationException(__('Super-Admins können nur von Super-Admins im Panel angemeldet werden.'));
|
||||
}
|
||||
|
||||
session([self::SessionKey => $admin->getKey()]);
|
||||
|
||||
Auth::login($target);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue