Loheide-eu-mitarbeiterplatt.../app/Identity/IdentityDrivers.php
Friederich Loheide 4fcc41ed30
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
Phase 6 (Teil 2): OpenID Connect, LDAP/AD und SAML 2
- 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>
2026-09-26 12:38:32 +00:00

57 lines
1.3 KiB
PHP

<?php
namespace App\Identity;
use Illuminate\Contracts\Container\Container;
/**
* Registry der Anmeldeverfahren. Der Kern bringt Entra ID mit, Plugins melden
* weitere an: $drivers->add('oidc', OidcDriver::class).
*/
class IdentityDrivers
{
/** @var array<string, class-string<IdentityDriver>> */
private array $classes = [];
/** @var array<string, IdentityDriver> */
private array $instances = [];
public function __construct(private readonly Container $container) {}
/**
* @param class-string<IdentityDriver> $class
*/
public function add(string $type, string $class): void
{
$this->classes[$type] = $class;
unset($this->instances[$type]);
}
public function has(string $type): bool
{
return isset($this->classes[$type]);
}
public function get(string $type): ?IdentityDriver
{
if (! isset($this->classes[$type])) {
return null;
}
return $this->instances[$type] ??= $this->container->make($this->classes[$type]);
}
/**
* @return array<string, IdentityDriver>
*/
public function all(): array
{
$all = [];
foreach (array_keys($this->classes) as $type) {
$all[$type] = $this->get($type);
}
return $all;
}
}