Rollen, Rechte und Zielgruppen
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m30s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m28s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m31s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m36s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 1m45s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 1m44s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 1m35s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 1m38s
CI / Build-Artefakte aktuell (pull_request) Successful in 54s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m30s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m28s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m31s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m36s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 1m45s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 1m44s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 1m35s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 1m38s
CI / Build-Artefakte aktuell (pull_request) Successful in 54s
- Rollen mit globalen Rechten und Rechten für einzelne Objekte (z. B. „Beiträge schreiben in Kategorie MAV-Info“); Rollen sind additiv, Zuweisungen merken sich ihre Herkunft (manuell oder später Identity-Provider-Gruppe) - Systemrolle „Administration“ ersetzt users.is_admin (Migration übernimmt bestehende Administratoren); nicht löschbar, man kann sie sich nicht selbst entziehen - Rechte je Person vorberechnet und gecacht, Versionszähler invalidiert bei Änderungen - Gate-Anbindung: registrierte Rechte entscheidet das Rechtesystem, Objektregeln die Policies; Admin-Seiten und Plugin-Ressourcen hinter passenden Rechten - Redaktion nach Kategorie: Schreiben und Veröffentlichen getrennt, Liste im Admin auf eigene Kategorien beschränkt, ohne Veröffentlichungsrecht bleibt ein Beitrag Entwurf - Zielgruppen (Rolle/Abteilung/Standort) für Kategorien und Termine als indizierte SQL-Bedingung in Listen, Detailseiten, Kacheln und .ics-Export - Admin: Rollen-Verwaltung, „Rechte prüfen“, Redaktion und Sichtbarkeit direkt an Kategorie bzw. Termin - Kern-Ressourcen explizit registriert, damit nach Updates liegengebliebene alte Dateien nicht doppelt geladen werden - docs/PLUGINS.md für Plugin-Entwicklung; Demo-Rolle „MAV“ Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
28ef1e4a20
commit
9ddc35a62c
112 changed files with 2408 additions and 267 deletions
|
|
@ -32,6 +32,11 @@ class Appearance extends Page
|
|||
|
||||
protected static ?string $title = 'Erscheinungsbild';
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('appearance.manage') ?? false;
|
||||
}
|
||||
|
||||
protected static ?string $slug = 'erscheinungsbild';
|
||||
|
||||
/** @var array<string, mixed>|null */
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@ class Feedback extends Page
|
|||
|
||||
protected static ?string $title = 'Rückmeldung geben';
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('feedback.send') ?? false;
|
||||
}
|
||||
|
||||
protected static ?string $slug = 'rueckmeldung';
|
||||
|
||||
public string $type = '';
|
||||
|
|
|
|||
102
app/Filament/Pages/PermissionChecker.php
Normal file
102
app/Filament/Pages/PermissionChecker.php
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Grant;
|
||||
use App\Models\User;
|
||||
use App\Support\Abilities;
|
||||
use BackedEnum;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use UnitEnum;
|
||||
|
||||
/**
|
||||
* „Was darf Person X – und warum?“ Zeigt Rollen samt Herkunft und alle Rechte
|
||||
* mit der Rolle, aus der sie stammen.
|
||||
*/
|
||||
class PermissionChecker extends Page
|
||||
{
|
||||
protected string $view = 'filament.pages.permission-checker';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedMagnifyingGlassCircle;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Benutzer & Rechte';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
protected static ?string $title = 'Rechte prüfen';
|
||||
|
||||
protected static ?string $slug = 'rechte-pruefen';
|
||||
|
||||
public ?int $userId = null;
|
||||
|
||||
public string $search = '';
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('roles.manage') ?? false;
|
||||
}
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->userId = request()->integer('person') ?: null;
|
||||
}
|
||||
|
||||
public function selectUser(int $id): void
|
||||
{
|
||||
$this->userId = $id;
|
||||
$this->search = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function getViewData(): array
|
||||
{
|
||||
$abilities = app(Abilities::class);
|
||||
$user = $this->userId ? User::query()->find($this->userId) : null;
|
||||
|
||||
$results = strlen($this->search) >= 2
|
||||
? User::query()->where(fn ($q) => $q->where('name', 'like', "%{$this->search}%")->orWhere('email', 'like', "%{$this->search}%"))->orderBy('name')->limit(8)->get()
|
||||
: collect();
|
||||
|
||||
$roles = collect();
|
||||
$global = collect();
|
||||
$objects = collect();
|
||||
|
||||
if ($user) {
|
||||
$roles = DB::table('role_user')->join('roles', 'roles.id', '=', 'role_user.role_id')
|
||||
->where('role_user.user_id', $user->id)
|
||||
->orderBy('roles.name')
|
||||
->get(['roles.id', 'roles.name', 'role_user.source', 'role_user.source_ref']);
|
||||
|
||||
$grants = Grant::query()->with('role')->whereIn('role_id', $roles->pluck('id')->unique())->get();
|
||||
$types = $abilities->resourceTypes();
|
||||
|
||||
$global = $grants->whereNull('resource_type')->map(fn (Grant $g) => [
|
||||
'label' => $g->ability === '*' ? 'Alle Rechte (voller Zugriff)' : $abilities->label($g->ability),
|
||||
'role' => $g->role->name,
|
||||
])->sortBy('label')->values();
|
||||
|
||||
$objects = $grants->whereNotNull('resource_type')->map(function (Grant $g) use ($abilities, $types) {
|
||||
$options = isset($types[$g->resource_type]) ? ($types[$g->resource_type]['options'])() : [];
|
||||
|
||||
return [
|
||||
'label' => $abilities->label($g->ability),
|
||||
'object' => ($types[$g->resource_type]['label'] ?? $g->resource_type).': '.($g->resource_id === null ? 'alle' : ($options[$g->resource_id] ?? '#'.$g->resource_id)),
|
||||
'role' => $g->role->name,
|
||||
];
|
||||
})->sortBy('label')->values();
|
||||
}
|
||||
|
||||
return [
|
||||
'user' => $user,
|
||||
'results' => $results,
|
||||
'roles' => $roles,
|
||||
'global' => $global,
|
||||
'objects' => $objects,
|
||||
'canAdmin' => $user?->canAccessAdmin() ?? false,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -28,6 +28,11 @@ class QuickLinksSettings extends Page
|
|||
|
||||
protected static ?string $title = 'Schnellzugriffe';
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('appearance.manage') ?? false;
|
||||
}
|
||||
|
||||
protected static ?string $slug = 'schnellzugriffe';
|
||||
|
||||
/** @var array<string, mixed>|null */
|
||||
|
|
|
|||
|
|
@ -23,6 +23,11 @@ class SystemHealth extends Page
|
|||
|
||||
protected static ?string $title = 'Systemzustand';
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('updates.manage') ?? false;
|
||||
}
|
||||
|
||||
protected static ?string $slug = 'systemzustand';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ class Updates extends Page
|
|||
|
||||
protected static ?string $title = 'Aktualisierung';
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('updates.manage') ?? false;
|
||||
}
|
||||
|
||||
protected static ?string $slug = 'aktualisierung';
|
||||
|
||||
public string $licenseEmail = '';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue