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
|
|
@ -3,15 +3,21 @@
|
|||
namespace App\Models;
|
||||
|
||||
use App\Identity\Entra\EntraAttributes;
|
||||
use App\Identity\IdentityDriver;
|
||||
use App\Identity\IdentityDrivers;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Ein angebundener Identity Provider (zunächst Microsoft Entra ID).
|
||||
* Ein angebundener Identity Provider. Das Verfahren (type) liefert ein Treiber aus
|
||||
* App\Identity\IdentityDrivers – Entra ID im Kern, OpenID Connect, LDAP und SAML als Plugins.
|
||||
*
|
||||
* config (verschlüsselt): tenant_id, client_id, client_secret, button_label,
|
||||
* config (verschlüsselt), gemeinsam: button_label, auto_provision, link_by_email,
|
||||
* allowed_domains, default_role_id, attribute_map, sync_manager, sync_photo;
|
||||
* übrige Schlüssel je Verfahren. Entra: tenant_id, client_id, client_secret, button_label,
|
||||
* auto_provision, link_by_email, allowed_domains, default_role_id,
|
||||
* attribute_map (Liste aus target + attribute), sync_manager, sync_photo,
|
||||
* extension_properties, directory_sync, directory_create_users
|
||||
|
|
@ -50,6 +56,31 @@ class IdentityProvider extends Model
|
|||
];
|
||||
}
|
||||
|
||||
public function driver(): ?IdentityDriver
|
||||
{
|
||||
return app(IdentityDrivers::class)->get((string) $this->type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktive Anbieter, deren Verfahren verfügbar ist – für die Anmeldeseite.
|
||||
*
|
||||
* @return Collection<int, IdentityProvider>
|
||||
*/
|
||||
public static function forLogin(): Collection
|
||||
{
|
||||
return static::query()->where('enabled', true)->orderBy('name')->get()
|
||||
->filter(fn (IdentityProvider $p) => $p->driver()?->unavailableReason() === null && $p->driver() !== null)
|
||||
->values();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{slug: string, label: string, type: string}
|
||||
*/
|
||||
public function toLoginButton(): array
|
||||
{
|
||||
return ['slug' => $this->slug, 'label' => $this->buttonLabel(), 'type' => $this->type];
|
||||
}
|
||||
|
||||
public function setting(string $key, mixed $default = null): mixed
|
||||
{
|
||||
return data_get($this->config, $key, $default);
|
||||
|
|
@ -66,6 +97,10 @@ class IdentityProvider extends Model
|
|||
{
|
||||
$rows = $this->setting('attribute_map');
|
||||
|
||||
if (! is_array($rows) && $this->type !== self::ENTRA) {
|
||||
return $this->driver()?->defaultAttributeMap() ?? [];
|
||||
}
|
||||
|
||||
if (! is_array($rows)) {
|
||||
$legacy = (array) $this->setting('synced_fields', array_keys(EntraAttributes::DEFAULT_MAP));
|
||||
|
||||
|
|
@ -73,12 +108,13 @@ class IdentityProvider extends Model
|
|||
}
|
||||
|
||||
$map = [];
|
||||
$pattern = $this->driver()?->attributePattern() ?? EntraAttributes::PATH_PATTERN;
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$target = (string) ($row['target'] ?? '');
|
||||
$attribute = trim((string) ($row['attribute'] ?? ''));
|
||||
|
||||
if ($attribute !== '' && preg_match(EntraAttributes::PATH_PATTERN, $attribute)
|
||||
if ($attribute !== '' && preg_match($pattern, $attribute)
|
||||
&& (array_key_exists($target, self::PROFILE_TARGETS) || str_starts_with($target, 'custom.'))) {
|
||||
$map[$target] = $attribute;
|
||||
}
|
||||
|
|
@ -89,6 +125,10 @@ class IdentityProvider extends Model
|
|||
|
||||
public function syncsManager(): bool
|
||||
{
|
||||
if ($this->type !== self::ENTRA) {
|
||||
return (bool) $this->setting('sync_manager', false) && (bool) $this->driver()?->supportsManager();
|
||||
}
|
||||
|
||||
return (bool) $this->setting('sync_manager', in_array('manager', (array) $this->setting('synced_fields', ['manager']), true));
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +144,7 @@ class IdentityProvider extends Model
|
|||
|
||||
public function buttonLabel(): string
|
||||
{
|
||||
return $this->setting('button_label') ?: 'Mit Microsoft anmelden';
|
||||
return $this->setting('button_label') ?: ($this->driver()?->defaultButtonLabel($this) ?? 'Mit '.$this->name.' anmelden');
|
||||
}
|
||||
|
||||
public function isEmailDomainAllowed(?string $email): bool
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue