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
112
app/Identity/AttributeProfile.php
Normal file
112
app/Identity/AttributeProfile.php
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
namespace App\Identity;
|
||||
|
||||
use App\Models\IdentityProvider;
|
||||
|
||||
/**
|
||||
* Baut aus den Attributen eines Anbieters (Claims, LDAP-Attribute, SAML-Attribute)
|
||||
* das normalisierte Profil – gemäß der Attribut-Zuordnung des Anbieters.
|
||||
*/
|
||||
final class AttributeProfile
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $attributes
|
||||
* @param array<string, string> $defaults Grundwerte (display_name, first_name, last_name, email) => Attribut
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function build(IdentityProvider $provider, array $attributes, array $defaults): array
|
||||
{
|
||||
$profile = [];
|
||||
|
||||
foreach ($defaults as $field => $attribute) {
|
||||
$profile[$field] = self::value($attributes, $attribute);
|
||||
}
|
||||
|
||||
foreach ($provider->attributeMap() as $target => $attribute) {
|
||||
$value = self::value($attributes, $attribute);
|
||||
|
||||
if (str_starts_with($target, 'custom.')) {
|
||||
$profile['custom'][substr($target, 7)] = $value;
|
||||
} else {
|
||||
$profile[$target] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wert eines Attributs als Text. Erst exakter Name (auch ohne Groß-/Kleinschreibung,
|
||||
* wie bei LDAP), dann Pfad mit Punkten für verschachtelte Claims. Listen werden mit
|
||||
* Komma verbunden.
|
||||
*
|
||||
* @param array<string, mixed> $attributes
|
||||
*/
|
||||
public static function value(array $attributes, string $name): ?string
|
||||
{
|
||||
$value = self::raw($attributes, $name);
|
||||
|
||||
if (is_array($value)) {
|
||||
$value = implode(', ', array_filter(array_map(fn ($v) => is_scalar($v) ? trim((string) $v) : null, $value), fn ($v) => $v !== null && $v !== ''));
|
||||
} elseif (is_bool($value)) {
|
||||
$value = $value ? 'ja' : 'nein';
|
||||
} elseif (! is_scalar($value)) {
|
||||
$value = null;
|
||||
}
|
||||
|
||||
$value = $value === null ? null : trim((string) $value);
|
||||
|
||||
return $value === '' || ($value !== null && ! mb_check_encoding($value, 'UTF-8')) ? null : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Liste von Werten (z. B. Gruppen).
|
||||
*
|
||||
* @param array<string, mixed> $attributes
|
||||
* @return list<string>
|
||||
*/
|
||||
public static function values(array $attributes, string $name): array
|
||||
{
|
||||
$value = self::raw($attributes, $name);
|
||||
$list = is_array($value) ? $value : ($value === null ? [] : [$value]);
|
||||
|
||||
return array_values(array_filter(array_map(fn ($v) => is_scalar($v) ? trim((string) $v) : '', $list), fn ($v) => $v !== ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $attributes
|
||||
*/
|
||||
public static function raw(array $attributes, string $name): mixed
|
||||
{
|
||||
if ($name === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (array_key_exists($name, $attributes)) {
|
||||
return $attributes[$name];
|
||||
}
|
||||
|
||||
foreach ($attributes as $key => $value) {
|
||||
if (is_string($key) && strcasecmp($key, $name) === 0) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (! str_contains($name, '.')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$value = $attributes;
|
||||
|
||||
foreach (explode('.', $name) as $segment) {
|
||||
if (! is_array($value) || ! array_key_exists($segment, $value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$value = $value[$segment];
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue