Sicherheitsupdate nach Audit (0.29.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 7m50s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m34s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m45s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 5m30s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m7s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m9s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m8s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 6m5s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 48s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m5s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-27 11:34:54 +00:00
parent a37895a16a
commit f1202bea08
226 changed files with 1952 additions and 450 deletions

View file

@ -5,6 +5,7 @@ namespace App\Filament\Resources\Users\Schemas;
use App\Models\ProfileField;
use App\Models\Role;
use App\Models\User;
use App\Support\Permissions\RoleGuard;
use App\Support\ProfileFields;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Select;
@ -104,12 +105,23 @@ class UserForm
->multiple()
->preload()
->options(fn () => Role::query()->orderByDesc('is_system')->orderBy('name')->pluck('name', 'id')->all())
// Nur Rollen, deren Rechte man selbst besitzt (nie „Administration“ ohne Vollzugriff)
->disableOptionWhen(fn (string $value) => ! RoleGuard::canAssign(auth()->user(), Role::query()->findOrFail((int) $value)))
->afterStateHydrated(function (Select $component, ?User $record) {
$component->state($record?->roles()->wherePivot('source', 'manual')->pluck('roles.id')->all() ?? []);
})
->rule(function (?User $record) {
// Die eigene Administrationsrolle kann man sich nicht selbst entziehen.
return function (string $attribute, mixed $value, \Closure $fail) use ($record) {
$before = $record?->roles()->wherePivot('source', 'manual')->pluck('roles.id')->all() ?? [];
$changed = array_merge(array_diff(array_map('intval', (array) $value), $before), array_diff($before, array_map('intval', (array) $value)));
foreach (Role::query()->whereIn('id', $changed)->get() as $role) {
if (! RoleGuard::canAssign(auth()->user(), $role)) {
$fail("Die Rolle „{$role->name}“ enthält Rechte, die Sie selbst nicht haben.");
}
}
// Die eigene Administrationsrolle kann man sich nicht selbst entziehen.
if ($record?->is(auth()->user()) && $record->hasRole(Role::ADMINISTRATION)
&& ! in_array(Role::administration()->id, array_map('intval', (array) $value), true)) {
$fail('Die eigene Rolle „Administration“ kann nicht entfernt werden.');