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

- 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:
Friederich Loheide 2026-09-26 12:38:32 +00:00
parent 0ab0838050
commit 4fcc41ed30
172 changed files with 18940 additions and 293 deletions

View file

@ -0,0 +1,167 @@
<?php
namespace App\Identity;
use App\Models\IdentityProvider;
use App\Models\User;
use Filament\Actions\Action;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* Ein Anmeldeverfahren (Entra ID, OpenID Connect, LDAP, SAML …). Plugins melden
* weitere Verfahren über App\Identity\IdentityDrivers an.
*
* Ablauf: start() leitet zum Anbieter weiter oder zeigt ein eigenes Formular;
* complete() wertet die Rückkehr aus. Die meisten Verfahren liefern dafür nur
* authenticate() – Konto, Profil und Rollen übernimmt der Kern (IdentityLogin).
*/
abstract class IdentityDriver
{
/** Kürzel, wie es in identity_providers.type steht. */
abstract public function type(): string;
/** z. B. „OpenID Connect“ */
abstract public function label(): string;
public function description(): string
{
return '';
}
public function defaultButtonLabel(IdentityProvider $provider): string
{
return 'Mit '.$provider->name.' anmelden';
}
/**
* Grund, warum das Verfahren auf diesem Server nicht nutzbar ist (z. B. fehlende
* PHP-Erweiterung) – oder null.
*/
public function unavailableReason(): ?string
{
return null;
}
/**
* Filament-Felder für die Verbindung (Speicherort: config.*).
*
* @return list<mixed>
*/
abstract public function connectionSchema(): array;
/** Hinweistext über den Verbindungsfeldern (HTML erlaubt, bereits escaped). */
public function connectionHelp(?IdentityProvider $provider): string
{
return '';
}
/**
* Zusätzliche Aktionen am Verbindungsabschnitt im Admin (z. B. „Verbindung testen“).
* Werden nur beim Bearbeiten angezeigt.
*
* @return list<Action>
*/
public function adminActions(): array
{
return [];
}
/**
* Konfigurationswerte, die nie ins Formular gelangen und beim Speichern mit
* leerem Feld erhalten bleiben.
*
* @return list<string>
*/
public function secretFields(): array
{
return [];
}
/**
* Standardzuordnung Profilfeld => Attribut für neue Anbieter.
*
* @return array<string, string>
*/
public function defaultAttributeMap(): array
{
return [];
}
/**
* Vorschläge für die Attributauswahl: Attribut => Bezeichnung.
*
* @return array<string, string>
*/
public function attributeSuggestions(?IdentityProvider $provider): array
{
return [];
}
/** Erlaubte Attributnamen – großzügig, weil SAML URIs und LDAP Bindestriche nutzt. */
public function attributePattern(): string
{
return '/^[^\s<>"\'\\\\]{1,191}$/';
}
public function attributeLabel(): string
{
return 'Attribut';
}
public function supportsManager(): bool
{
return false;
}
public function supportsPhoto(): bool
{
return false;
}
public function supportsAppRoles(): bool
{
return false;
}
/** Beschriftung für den Wert einer Gruppe in der Rollen-Zuordnung. */
public function groupValueLabel(): string
{
return 'Gruppe (Wert wie übermittelt)';
}
/** Anmeldung beginnen: Weiterleitung zum Anbieter oder eigenes Formular. */
abstract public function start(IdentityProvider $provider, Request $request): Response;
/**
* Rückkehr bzw. Formular auswerten und die angemeldete Person liefern.
*
* @throws IdentityException mit einer Meldung für die Person
*/
public function complete(IdentityProvider $provider, Request $request): User
{
return app(IdentityLogin::class)->finish($provider, $this->authenticate($provider, $request));
}
/**
* Identität beim Anbieter bestätigen.
*
* @throws IdentityException
*/
protected function authenticate(IdentityProvider $provider, Request $request): ExternalUser
{
throw new IdentityException('Dieses Anmeldeverfahren ist nicht vollständig eingerichtet.');
}
/** Wohin es nach der Anmeldung geht (z. B. aus einem RelayState) – null = gemerkte Seite. */
public function intendedUrl(IdentityProvider $provider, Request $request): ?string
{
return null;
}
/** Zusätzliche öffentliche Antwort, z. B. SAML-Metadaten. */
public function metadata(IdentityProvider $provider): ?Response
{
return null;
}
}