Loheide-eu-mitarbeiterplatt.../app/Providers/AppServiceProvider.php
Friederich Loheide 9ddc35a62c
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, Rechte und Zielgruppen
- 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>
2026-09-26 07:18:37 +00:00

78 lines
2.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Providers;
use App\Dashboard\CoreWidgets;
use App\Dashboard\Widgets;
use App\Models\User;
use App\Support\Abilities;
use App\Support\Avatars;
use App\Support\BackgroundTasks;
use App\Support\Branding;
use App\Support\Installation;
use App\Support\License\LicenseStore;
use App\Support\Permissions\PermissionResource;
use App\Support\Permissions\Permissions;
use App\Support\QuickLinks;
use App\Support\Settings;
use App\Support\Update\InstalledVersion;
use App\Support\Update\MaintenanceFlag;
use App\Support\Update\UpdateProgress;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
use Illuminate\Validation\Rules\Password;
class AppServiceProvider extends ServiceProvider
{
public function register(): void
{
// Frisch hochgeladen: .env und Schlüssel anlegen; bis zur Einrichtung ohne Datenbank
// für Sitzungen, Cache und Queue auskommen (der Web-Installer braucht das).
if (! $this->app->runningUnitTests()) {
Installation::prepareEnvironment();
}
if (! Installation::isInstalled()) {
config(['session.driver' => 'file', 'cache.default' => 'file', 'queue.default' => 'sync']);
}
$this->app->singleton(Settings::class);
$this->app->singleton(Branding::class);
$this->app->singleton(Avatars::class);
$this->app->singleton(QuickLinks::class);
$this->app->singleton(LicenseStore::class);
$this->app->singleton(Permissions::class);
$this->app->singleton(BackgroundTasks::class);
$this->app->singleton(InstalledVersion::class);
$this->app->singleton(UpdateProgress::class);
$this->app->singleton(MaintenanceFlag::class);
}
public function boot(): void
{
CoreWidgets::register($this->app->make(Widgets::class));
// N+1-Abfragen in Entwicklung und Tests sofort sichtbar machen (docs/PLAN.md, Performance).
Model::preventLazyLoading(! $this->app->isProduction());
// Rechte aus Rollen (App\Support\Abilities) entscheidet das Rechtesystem – Administration
// hat sie alle. Alles andere (z. B. „delete“ auf einem Modell) entscheiden die Policies,
// damit Regeln wie „Systemrollen nie löschen“ auch für Administratoren gelten.
Gate::before(function (User $user, string $ability, array $arguments) {
if (! $user->is_active) {
return false;
}
if (! $this->app->make(Abilities::class)->exists($ability)) {
return null;
}
[$type, $id] = PermissionResource::from($arguments);
return $user->permissions()->can($ability, $type, $id);
});
Password::defaults(fn () => Password::min(10)->letters()->numbers());
}
}