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
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:
parent
a37895a16a
commit
f1202bea08
226 changed files with 1952 additions and 450 deletions
46
app/Filament/Components/SafeUpload.php
Normal file
46
app/Filament/Components/SafeUpload.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Components;
|
||||
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
|
||||
/**
|
||||
* Uploads in den öffentlichen Ordner (public/uploads): nur bestimmte Dateitypen, und
|
||||
* die Dateiendung ergibt sich aus dem geprüften Inhalt – nie aus dem Namen der
|
||||
* hochgeladenen Datei (sonst ließe sich z. B. „bild.html“ oder „bild.php“ ablegen).
|
||||
*/
|
||||
final class SafeUpload
|
||||
{
|
||||
public const IMAGES = ['image/jpeg', 'image/png', 'image/webp', 'image/gif'];
|
||||
|
||||
public const EXTENSIONS = [
|
||||
'image/jpeg' => 'jpg',
|
||||
'image/png' => 'png',
|
||||
'image/webp' => 'webp',
|
||||
'image/gif' => 'gif',
|
||||
'image/svg+xml' => 'svg',
|
||||
'image/x-icon' => 'ico',
|
||||
'image/vnd.microsoft.icon' => 'ico',
|
||||
'font/woff2' => 'woff2',
|
||||
'application/font-woff2' => 'woff2',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param list<string> $types erlaubte MIME-Typen
|
||||
*/
|
||||
public static function apply(FileUpload $upload, array $types = self::IMAGES, ?string $forcedExtension = null): FileUpload
|
||||
{
|
||||
return $upload
|
||||
->acceptedFileTypes($types)
|
||||
->getUploadedFileNameForStorageUsing(fn (TemporaryUploadedFile $file) => self::name($file, $forcedExtension));
|
||||
}
|
||||
|
||||
public static function name(TemporaryUploadedFile $file, ?string $forcedExtension = null): string
|
||||
{
|
||||
$extension = $forcedExtension ?? self::EXTENSIONS[strtolower((string) $file->getMimeType())] ?? 'bin';
|
||||
|
||||
return Str::ulid().'.'.$extension;
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Filament\Pages\Appearance;
|
||||
|
||||
use App\Filament\Clusters\AppearanceCluster;
|
||||
use App\Filament\Components\SafeUpload;
|
||||
use App\Support\Audit;
|
||||
use App\Support\Branding;
|
||||
use App\Support\Theme\Contrast;
|
||||
|
|
@ -45,7 +46,7 @@ abstract class AppearancePage extends Page
|
|||
|
||||
protected static function image(string $name, string $label, string $help): FileUpload
|
||||
{
|
||||
return FileUpload::make($name)->label($label)->helperText($help)
|
||||
return SafeUpload::apply(FileUpload::make($name), [...SafeUpload::IMAGES, 'image/svg+xml'])->label($label)->helperText($help)
|
||||
->disk('uploads')->directory('theme')->visibility('public')->maxSize(4096);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Filament\Pages\Appearance;
|
||||
|
||||
use App\Filament\Components\SafeUpload;
|
||||
use App\Support\Theme\Fonts;
|
||||
use App\Support\Theme\Theme;
|
||||
use BackedEnum;
|
||||
|
|
@ -32,6 +33,7 @@ class AppearanceTypography extends AppearancePage
|
|||
->helperText('Z. B. die Hausschrift aus dem Corporate Design. Wird lokal ausgeliefert – keine Verbindung zu Google oder anderen Diensten. Bitte die Lizenz für die Nutzung im Web beachten.')
|
||||
->disk('uploads')->directory('theme/fonts')->visibility('public')->maxSize(2048)
|
||||
->acceptedFileTypes(['font/woff2', 'application/font-woff2', 'application/octet-stream'])
|
||||
->getUploadedFileNameForStorageUsing(fn ($file) => SafeUpload::name($file, 'woff2'))
|
||||
->rule('extensions:woff2')->live()->columnSpanFull(),
|
||||
Radio::make('radius')->label('Ecken')->options(collect(Theme::RADII)->map(fn ($r) => $r[0])->all())->inline()->required(),
|
||||
Radio::make('density')->label('Abstände')->options(collect(Theme::DENSITIES)->map(fn ($d) => $d[0])->all())->inline()->required(),
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace App\Filament\Resources\DashboardTiles;
|
|||
|
||||
use App\Filament\Clusters\HomepageCluster;
|
||||
use App\Filament\Components\AudienceSection;
|
||||
use App\Filament\Components\SafeUpload;
|
||||
use App\Filament\Resources\DashboardTiles\Pages\ManageDashboardTiles;
|
||||
use App\Models\DashboardTile;
|
||||
use BackedEnum;
|
||||
|
|
@ -60,7 +61,7 @@ class DashboardTileResource extends Resource
|
|||
->helperText('Die Reihenfolge innerhalb des Bereichs legen Sie unter „Startseite“ fest.'),
|
||||
TextInput::make('title')->label(fn (Get $get) => $get('type') === 'image' ? 'Bildunterschrift (optional)' : 'Überschrift')->maxLength(150),
|
||||
|
||||
FileUpload::make('image_path')->label('Bild')->image()->disk('uploads')->directory('dashboard')->visibility('public')
|
||||
SafeUpload::apply(FileUpload::make('image_path'))->label('Bild')->image()->disk('uploads')->directory('dashboard')->visibility('public')
|
||||
->maxSize(8 * 1024)->required($type('image'))->visible($type('image'))->columnSpanFull()
|
||||
->helperText('Für die Seitenleiste z. B. 800 × 600 Pixel, für „ganz oben“ ein breites Banner (z. B. 2400 × 500).'),
|
||||
TextInput::make('alt')->label('Alternativtext')->maxLength(200)->visible($type('image'))->helperText('Beschreibt das Bild für Screenreader.'),
|
||||
|
|
|
|||
|
|
@ -339,6 +339,9 @@ class IdentityProviderResource extends Resource
|
|||
->schema([
|
||||
Toggle::make('config.auto_provision')->label('Konto bei erster Anmeldung anlegen')->default(true),
|
||||
Toggle::make('config.link_by_email')->label('Bestehende Konten über die E-Mail-Adresse verknüpfen')->default(true),
|
||||
Toggle::make('config.trust_email')->label('E-Mail-Adressen dieses Anbieters sind geprüft')
|
||||
->helperText('Nur einschalten, wenn niemand beim Anbieter seine E-Mail-Adresse selbst ändern kann. Sonst werden Konten mit Passwort oder Administrationsrechten nicht automatisch verknüpft (Schutz vor Kontoübernahme).')
|
||||
->visible(fn ($get) => ($get('type') ?? null) !== 'entra'),
|
||||
TagsInput::make('config.allowed_domains')->label('Erlaubte E-Mail-Domains')->placeholder('firma.de')
|
||||
->helperText('Leer = alle Konten des Anbieters.'),
|
||||
Select::make('config.default_role_id')->label('Standardrolle für alle')
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use Filament\Actions\Action;
|
|||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class EditIdentityProvider extends EditRecord
|
||||
{
|
||||
|
|
@ -38,8 +39,16 @@ class EditIdentityProvider extends EditRecord
|
|||
*/
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
{
|
||||
$destinationChanged = collect($this->record->driver()?->destinationFields() ?? [])
|
||||
->contains(fn (string $field) => (string) ($data['config'][$field] ?? '') !== (string) ($this->record->setting($field) ?? ''));
|
||||
|
||||
foreach ($this->secretFields() as $field) {
|
||||
if (blank($data['config'][$field] ?? null)) {
|
||||
// Gespeichertes Geheimnis nur für dasselbe Ziel weiterverwenden
|
||||
if ($destinationChanged && filled($this->record->setting($field))) {
|
||||
throw ValidationException::withMessages(["data.config.{$field}" => 'Server bzw. Aussteller wurden geändert – bitte das Geheimnis erneut eingeben.']);
|
||||
}
|
||||
|
||||
$data['config'][$field] = $this->record->setting($field);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,15 @@
|
|||
namespace App\Filament\Resources\ProfileFields\Pages;
|
||||
|
||||
use App\Filament\Resources\ProfileFields\ProfileFieldResource;
|
||||
use App\Support\Audit;
|
||||
use App\Support\ProfileFields;
|
||||
use App\Support\Settings;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class ManageProfileFields extends ManageRecords
|
||||
{
|
||||
|
|
@ -13,6 +20,18 @@ class ManageProfileFields extends ManageRecords
|
|||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('settings')->label('Selbst pflegen')->icon(Heroicon::OutlinedCog6Tooth)->color('gray')
|
||||
->modalHeading('Was Mitarbeitende selbst ändern dürfen')
|
||||
->fillForm(fn () => ['self_edit_org' => (bool) app(Settings::class)->get(ProfileFields::SELF_EDIT_ORG, false)])
|
||||
->schema([
|
||||
Toggle::make('self_edit_org')->label('Abteilung und Standort selbst ändern')
|
||||
->helperText('Vorsicht: Abteilung und Standort bestimmen, wer welche Inhalte sieht (Zielgruppen). Wer sie selbst ändern darf, kann sich so Zugang zu Inhalten anderer Abteilungen verschaffen. Die E-Mail-Adresse ändert immer die Administration unter „Benutzer“.'),
|
||||
])
|
||||
->action(function (array $data) {
|
||||
app(Settings::class)->set(ProfileFields::SELF_EDIT_ORG, (bool) $data['self_edit_org']);
|
||||
Audit::log('profile.self_edit_org', ['enabled' => (bool) $data['self_edit_org']]);
|
||||
Notification::make()->success()->title('Gespeichert')->send();
|
||||
}),
|
||||
CreateAction::make()->label('Profilfeld anlegen'),
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use App\Models\Role;
|
|||
use App\Models\User;
|
||||
use App\Support\Abilities;
|
||||
use App\Support\Permissions\Permissions;
|
||||
use App\Support\Permissions\RoleGuard;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
|
|
@ -71,6 +72,19 @@ class RoleResource extends Resource
|
|||
->options(fn () => collect($abilities->global())->map(fn (array $a) => $a['label'])->all())
|
||||
->descriptions(fn () => collect($abilities->global())->map(fn (array $a) => $a['group'].($a['portal'] ? ' · im Portal' : ' · Backend'))->all())
|
||||
->bulkToggleable()
|
||||
// Nur Rechte eintragen, die man selbst besitzt
|
||||
->disableOptionWhen(fn (string $value) => ! RoleGuard::canGrant(auth()->user(), $value))
|
||||
->rule(fn (?Role $record) => function (string $attribute, mixed $value, \Closure $fail) use ($record) {
|
||||
$before = $record?->grants()->whereNull('resource_type')->pluck('ability')->all() ?? [];
|
||||
|
||||
foreach (array_merge(array_diff((array) $value, $before), array_diff($before, (array) $value)) as $ability) {
|
||||
if (! RoleGuard::canGrant(auth()->user(), (string) $ability)) {
|
||||
$fail('Sie können nur Rechte vergeben oder entziehen, die Sie selbst haben.');
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
})
|
||||
->afterStateHydrated(fn (CheckboxList $component, ?Role $record) => $component->state(
|
||||
$record?->grants()->whereNull('resource_type')->pluck('ability')->all() ?? []
|
||||
))
|
||||
|
|
@ -164,6 +178,12 @@ class RoleResource extends Resource
|
|||
$record?->users()->wherePivot('source', 'manual')->pluck('users.id')->all() ?? []
|
||||
))
|
||||
->rule(fn (?Role $record) => function (string $attribute, mixed $value, \Closure $fail) use ($record) {
|
||||
$before = $record?->users()->wherePivot('source', 'manual')->pluck('users.id')->all() ?? [];
|
||||
|
||||
if ($record && array_diff(array_map('intval', (array) $value), $before) && ! RoleGuard::canAssign(auth()->user(), $record)) {
|
||||
$fail('Diese Rolle enthält Rechte, die Sie selbst nicht haben – Sie können keine Personen hinzufügen.');
|
||||
}
|
||||
|
||||
if ($record?->isAdministration() && ! in_array(auth()->id(), array_map('intval', (array) $value), true)) {
|
||||
$fail('Sie können sich nicht selbst aus der Rolle „Administration“ entfernen.');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue