Phase 6 (Teil 2): OpenID Connect, LDAP/AD und SAML 2
All checks were successful
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m41s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m48s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m15s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m17s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 3m48s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 3m41s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 3m33s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m26s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 3m59s
All checks were successful
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m41s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m48s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m15s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m17s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 3m48s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 3m41s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 3m33s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m26s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 3m59s
- Gemeinsamer Treiber-Unterbau (App\Identity\IdentityDriver, IdentityDrivers, IdentityLogin, AttributeProfile); Entra ID nutzt ihn ebenfalls - Plugins oidc, ldap und saml mit Profil- und Gruppen-Zuordnung - Admin: Verfahren wählen, Formular je Verfahren, zuletzt empfangene Angaben - onelogin/php-saml als neue Abhängigkeit Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0ab0838050
commit
4fcc41ed30
172 changed files with 18940 additions and 293 deletions
|
|
@ -10,6 +10,9 @@ use App\Http\Controllers\Auth\IdentityLoginController;
|
|||
use App\Identity\Entra\EntraAttributes;
|
||||
use App\Identity\Entra\EntraDirectorySync;
|
||||
use App\Identity\Entra\MappingTester;
|
||||
use App\Identity\IdentityDriver;
|
||||
use App\Identity\IdentityDrivers;
|
||||
use App\Identity\IdentityLogin;
|
||||
use App\Models\IdentityProvider;
|
||||
use App\Models\IdpGroupMapping;
|
||||
use App\Models\Role;
|
||||
|
|
@ -63,6 +66,33 @@ class IdentityProviderResource extends Resource
|
|||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
$type = static::typeFor($schema);
|
||||
|
||||
if ($type !== IdentityProvider::ENTRA) {
|
||||
return static::genericForm($schema, $type);
|
||||
}
|
||||
|
||||
return static::entraForm($schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verfahren des bearbeiteten bzw. neu anzulegenden Anbieters.
|
||||
*/
|
||||
public static function typeFor(Schema $schema): string
|
||||
{
|
||||
$record = $schema->getRecord();
|
||||
|
||||
if ($record instanceof IdentityProvider) {
|
||||
return (string) $record->type;
|
||||
}
|
||||
|
||||
$livewire = $schema->getLivewire();
|
||||
|
||||
return property_exists($livewire, 'type') && is_string($livewire->type) ? $livewire->type : IdentityProvider::ENTRA;
|
||||
}
|
||||
|
||||
public static function entraForm(Schema $schema): Schema
|
||||
{
|
||||
$guid = '/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i';
|
||||
|
||||
|
|
@ -96,17 +126,7 @@ class IdentityProviderResource extends Resource
|
|||
->helperText(fn (string $operation) => $operation === 'edit' ? 'Leer lassen, um den gespeicherten Schlüssel zu behalten.' : 'Der Wert (nicht die ID) des Geheimnisses.'),
|
||||
]),
|
||||
|
||||
Section::make('Konten')
|
||||
->columns(2)
|
||||
->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),
|
||||
TagsInput::make('config.allowed_domains')->label('Erlaubte E-Mail-Domains')->placeholder('firma.de')
|
||||
->helperText('Leer = alle Konten des Mandanten.'),
|
||||
Select::make('config.default_role_id')->label('Standardrolle für alle')
|
||||
->options(fn () => Role::query()->where('slug', '!=', Role::ADMINISTRATION)->orderBy('name')->pluck('name', 'id')->all())
|
||||
->helperText('z. B. „Mitarbeitende“ – erhält jede Person, die sich über Entra anmeldet.'),
|
||||
]),
|
||||
static::accountsSection('Personen, die sich über Entra anmelden'),
|
||||
|
||||
Section::make('Profil')
|
||||
->key('profile')
|
||||
|
|
@ -214,6 +234,156 @@ class IdentityProviderResource extends Resource
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formular für Verfahren aus Plugins (OpenID Connect, LDAP, SAML …).
|
||||
*/
|
||||
public static function genericForm(Schema $schema, string $type): Schema
|
||||
{
|
||||
$driver = app(IdentityDrivers::class)->get($type);
|
||||
|
||||
if (! $driver) {
|
||||
return $schema->components([
|
||||
Section::make('Verfahren nicht verfügbar')->schema([
|
||||
Text::make('Das Plugin für dieses Anmeldeverfahren („'.$type.'“) ist deaktiviert oder nicht installiert. Die Einstellungen bleiben erhalten; die Anmeldung ist abgeschaltet, bis das Plugin wieder aktiv ist.'),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
return $schema
|
||||
->columns(1)
|
||||
->components([
|
||||
Section::make($driver->label())
|
||||
->description($driver->description())
|
||||
->columns(2)
|
||||
->schema([
|
||||
Hidden::make('type')->default($type),
|
||||
TextInput::make('name')->label('Bezeichnung')->required()->maxLength(100)->default($driver->label())
|
||||
->helperText('Erscheint in Meldungen, z. B. „Anmeldung über …“.'),
|
||||
TextInput::make('config.button_label')->label('Text auf dem Anmeldeknopf')->maxLength(60)
|
||||
->placeholder(fn (?IdentityProvider $record) => $record?->buttonLabel() ?? 'Mit … anmelden'),
|
||||
Toggle::make('enabled')->label('Anmeldung aktiv')->columnSpanFull()
|
||||
->helperText('Zeigt den Knopf auf der Anmeldeseite. Die Anmeldung mit Passwort bleibt für Notfälle erhalten.'),
|
||||
Text::make(new HtmlString('<span style="color: rgb(220 38 38)">'.e((string) $driver->unavailableReason()).'</span>'))
|
||||
->visible($driver->unavailableReason() !== null)->columnSpanFull(),
|
||||
]),
|
||||
|
||||
Section::make('Verbindung')
|
||||
->key('connection')
|
||||
->description(fn (?IdentityProvider $record) => new HtmlString($driver->connectionHelp($record)))
|
||||
->afterHeader(fn (string $operation) => $operation === 'edit' ? $driver->adminActions() : [])
|
||||
->columns(2)
|
||||
->schema($driver->connectionSchema()),
|
||||
|
||||
static::accountsSection('Personen, die sich über dieses Verfahren anmelden'),
|
||||
|
||||
Section::make('Profil')
|
||||
->description('Welche Angaben des Anbieters in welches Profilfeld kommen. Zugeordnete Felder sind im Portal schreibgeschützt. Eigene Felder legen Sie unter „Profilfelder“ an.')
|
||||
->schema([
|
||||
Repeater::make('config.attribute_map')
|
||||
->hiddenLabel()
|
||||
->columns(3)
|
||||
->addActionLabel('Zuordnung hinzufügen')
|
||||
->reorderable(false)
|
||||
->default(fn () => collect($driver->defaultAttributeMap())->map(fn ($attribute, $target) => ['target' => $target, 'attribute' => $attribute])->values()->all())
|
||||
->itemLabel(fn (array $state) => static::profileTargets()[$state['target'] ?? ''] ?? null)
|
||||
->schema([
|
||||
Select::make('target')->label('Profilfeld')->required()->native(false)
|
||||
->options(fn () => static::profileTargets())
|
||||
->disableOptionsWhenSelectedInSiblingRepeaterItems(),
|
||||
Select::make('suggestion')->label('Auswählen')->placeholder('Aus der Liste übernehmen …')->searchable()->native(false)
|
||||
->options(fn (?IdentityProvider $record) => static::attributeOptions($driver, $record))
|
||||
->live()
|
||||
->afterStateUpdated(fn (?string $state, Set $set) => $state ? $set('attribute', $state) : null)
|
||||
->dehydrated(false),
|
||||
TextInput::make('attribute')->label($driver->attributeLabel())->required()->maxLength(191)
|
||||
->regex($driver->attributePattern())
|
||||
->validationMessages(['regex' => 'Bitte einen Attributnamen ohne Leerzeichen angeben.']),
|
||||
]),
|
||||
Toggle::make('config.sync_manager')->label('Vorgesetzte*n übernehmen')->default(true)->visible($driver->supportsManager())
|
||||
->helperText('Verknüpft wird, sobald sich die vorgesetzte Person einmal angemeldet hat.'),
|
||||
Toggle::make('config.sync_photo')->label('Profilfoto übernehmen')->default(true)->visible($driver->supportsPhoto()),
|
||||
]),
|
||||
|
||||
Section::make('Zuletzt empfangene Angaben')
|
||||
->description('Was der Anbieter bei der letzten Anmeldung übermittelt hat – hilft bei den Zuordnungen oben und unten.')
|
||||
->collapsible()
|
||||
->schema([Text::make(fn (?IdentityProvider $record) => static::lastSeenHtml($record))])
|
||||
->visible(fn (string $operation) => $operation === 'edit'),
|
||||
|
||||
Section::make('Gruppen → Rollen')
|
||||
->description('Personen in diesen Gruppen erhalten die Rolle im Portal. Rollen sind additiv; manuell vergebene Rollen bleiben unberührt. Groß- und Kleinschreibung spielt keine Rolle.')
|
||||
->schema([
|
||||
Repeater::make('mappings')
|
||||
->relationship()
|
||||
->hiddenLabel()
|
||||
->columns(3)
|
||||
->defaultItems(0)
|
||||
->addActionLabel('Zuordnung hinzufügen')
|
||||
->schema([
|
||||
Hidden::make('kind')->default(IdpGroupMapping::GROUP),
|
||||
TextInput::make('external_id')->label($driver->groupValueLabel())->required()->maxLength(191),
|
||||
TextInput::make('external_name')->label('Bezeichnung')->maxLength(191),
|
||||
Select::make('role_id')->label('Rolle im Portal')->required()
|
||||
->options(fn () => Role::query()->orderBy('name')->pluck('name', 'id')->all()),
|
||||
])
|
||||
->visible(fn (string $operation) => $operation === 'edit'),
|
||||
Text::make('Zuordnungen lassen sich nach dem ersten Speichern pflegen.')->visible(fn (string $operation) => $operation === 'create'),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function accountsSection(string $defaultRoleHelp): Section
|
||||
{
|
||||
return Section::make('Konten')
|
||||
->columns(2)
|
||||
->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),
|
||||
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')
|
||||
->options(fn () => Role::query()->where('slug', '!=', Role::ADMINISTRATION)->orderBy('name')->pluck('name', 'id')->all())
|
||||
->helperText('z. B. „Mitarbeitende“ – erhalten alle '.$defaultRoleHelp.'.'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private static function attributeOptions(IdentityDriver $driver, ?IdentityProvider $record): array
|
||||
{
|
||||
$options = collect($driver->attributeSuggestions($record))->mapWithKeys(fn ($label, $name) => [$name => $label.' · '.$name]);
|
||||
|
||||
// Tatsächlich empfangene Attribute der letzten Anmeldung.
|
||||
foreach (array_keys(($record ? IdentityLogin::lastSeen($record) : null)['attributes'] ?? []) as $name) {
|
||||
$options[$name] ??= $name.' (zuletzt empfangen)';
|
||||
}
|
||||
|
||||
return $options->all();
|
||||
}
|
||||
|
||||
public static function lastSeenHtml(?IdentityProvider $record): HtmlString
|
||||
{
|
||||
$seen = $record ? IdentityLogin::lastSeen($record) : null;
|
||||
|
||||
if (! $seen) {
|
||||
return new HtmlString('<span style="opacity:.7">Noch keine Anmeldung seit der Einrichtung.</span>');
|
||||
}
|
||||
|
||||
$rows = '';
|
||||
|
||||
foreach ($seen['attributes'] as $name => $value) {
|
||||
$rows .= '<tr><td style="padding:3px 12px 3px 0;vertical-align:top;font-family:ui-monospace,monospace;font-size:12px;word-break:break-all">'.e($name).'</td>'
|
||||
.'<td style="padding:3px 0;word-break:break-word">'.e($value).'</td></tr>';
|
||||
}
|
||||
|
||||
return new HtmlString(
|
||||
'<p style="margin-bottom:8px">'.e(Carbon::createFromTimestamp($seen['at'])->locale('de')->diffForHumans()).' · Kennung <code>'.e($seen['subject']).'</code></p>'
|
||||
.'<table style="width:100%;font-size:13px">'.$rows.'</table>'
|
||||
.'<p style="margin-top:8px"><strong>Gruppen:</strong> '.($seen['groups'] === [] ? 'keine' : e(implode(' · ', $seen['groups']))).'</p>'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string> Zielfeld => Bezeichnung
|
||||
*/
|
||||
|
|
@ -245,13 +415,15 @@ class IdentityProviderResource extends Resource
|
|||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')->label('Bezeichnung')->weight('medium'),
|
||||
TextColumn::make('type')->label('Typ')->formatStateUsing(fn () => 'Microsoft Entra ID'),
|
||||
TextColumn::make('type')->label('Verfahren')
|
||||
->formatStateUsing(fn (string $state) => app(IdentityDrivers::class)->get($state)?->label() ?? $state.' (Plugin deaktiviert)'),
|
||||
IconColumn::make('enabled')->label('Aktiv')->boolean(),
|
||||
TextColumn::make('mappings_count')->label('Zuordnungen')->counts('mappings'),
|
||||
TextColumn::make('identities_count')->label('Verknüpfte Konten')->counts('identities'),
|
||||
])
|
||||
->recordActions([
|
||||
Action::make('test')->label('Mapping testen')->icon(Heroicon::OutlinedBeaker)
|
||||
->visible(fn (IdentityProvider $record) => $record->type === IdentityProvider::ENTRA)
|
||||
->url(fn (IdentityProvider $record) => static::getUrl('test', ['record' => $record])),
|
||||
EditAction::make(),
|
||||
]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue