Beliebige Entra-Attribute ins Profil übernehmen; eigene Profilfelder
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m43s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m52s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m49s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m49s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 2m12s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 2m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 1m57s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 1m59s
CI / Build-Artefakte aktuell (pull_request) Successful in 57s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m43s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m52s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m49s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m49s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 2m12s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 2m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 1m57s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 1m59s
CI / Build-Artefakte aktuell (pull_request) Successful in 57s
- Profilfelder frei definierbar (Typ, Sichtbarkeit, selbst pflegbar), Werte als JSON am Benutzer - Attribut-Zuordnung je Anbieter statt fester Feldliste: jedes Graph-Attribut inkl. verschachtelter Pfade, onPremisesExtensionAttributes und Verzeichniserweiterungen - Erweiterungsattribute per Knopf aus Entra laden - $select dynamisch aus der Zuordnung; Delta-Abgleich startet bei geänderter Zuordnung neu - Rückfall auf Grundattribute, wenn einzelne Attribute nicht lesbar sind - Ältere Konfiguration (synced_fields) wird weiter gelesen Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
51c94cd0cf
commit
6269d3302c
79 changed files with 1442 additions and 273 deletions
141
app/Identity/Entra/EntraAttributes.php
Normal file
141
app/Identity/Entra/EntraAttributes.php
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
<?php
|
||||
|
||||
namespace App\Identity\Entra;
|
||||
|
||||
use App\Models\IdentityProvider;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
/**
|
||||
* Graph-Benutzerattribute: Vorschlagsliste, Standardzuordnung, $select-Aufbau
|
||||
* und das Auslesen verschachtelter Werte.
|
||||
*
|
||||
* Ein Attribut ist ein Pfad in der Graph-Antwort, z. B. „jobTitle“,
|
||||
* „employeeOrgData.costCenter“, „onPremisesExtensionAttributes.extensionAttribute3“,
|
||||
* „businessPhones.0“ oder „extension_<appId>_personalnummer“.
|
||||
*/
|
||||
final class EntraAttributes
|
||||
{
|
||||
/** Wird immer abgefragt – für Kontoanlage, Verknüpfung und Offboarding. */
|
||||
public const BASE_SELECT = ['id', 'displayName', 'givenName', 'surname', 'mail', 'userPrincipalName', 'accountEnabled', 'userType'];
|
||||
|
||||
/** Standardzuordnung Profilfeld => Attribut (entspricht dem bisherigen Verhalten). */
|
||||
public const DEFAULT_MAP = [
|
||||
'first_name' => 'givenName',
|
||||
'last_name' => 'surname',
|
||||
'email' => 'mail',
|
||||
'job_title' => 'jobTitle',
|
||||
'department' => 'department',
|
||||
'location' => 'officeLocation',
|
||||
'phone' => 'businessPhones.0',
|
||||
'mobile' => 'mobilePhone',
|
||||
];
|
||||
|
||||
/** Häufige Attribute als Vorschläge im Formular. */
|
||||
public const COMMON = [
|
||||
'givenName' => 'Vorname',
|
||||
'surname' => 'Nachname',
|
||||
'displayName' => 'Anzeigename',
|
||||
'mail' => 'E-Mail-Adresse',
|
||||
'userPrincipalName' => 'Benutzerprinzipalname',
|
||||
'jobTitle' => 'Position',
|
||||
'department' => 'Abteilung',
|
||||
'companyName' => 'Firmenname',
|
||||
'officeLocation' => 'Büro',
|
||||
'businessPhones.0' => 'Telefon (geschäftlich)',
|
||||
'mobilePhone' => 'Mobiltelefon',
|
||||
'faxNumber' => 'Fax',
|
||||
'streetAddress' => 'Straße',
|
||||
'postalCode' => 'Postleitzahl',
|
||||
'city' => 'Ort',
|
||||
'state' => 'Bundesland',
|
||||
'country' => 'Land',
|
||||
'usageLocation' => 'Nutzungsstandort',
|
||||
'preferredLanguage' => 'Bevorzugte Sprache',
|
||||
'employeeId' => 'Personalnummer',
|
||||
'employeeType' => 'Mitarbeitertyp',
|
||||
'employeeHireDate' => 'Eintrittsdatum',
|
||||
'employeeLeaveDateTime' => 'Austrittsdatum',
|
||||
'employeeOrgData.costCenter' => 'Kostenstelle',
|
||||
'employeeOrgData.division' => 'Bereich',
|
||||
'otherMails' => 'Weitere E-Mail-Adressen',
|
||||
'proxyAddresses' => 'Proxyadressen',
|
||||
'onPremisesSamAccountName' => 'Anmeldename (lokal)',
|
||||
'onPremisesDistinguishedName' => 'Distinguished Name (lokal)',
|
||||
'onPremisesExtensionAttributes.extensionAttribute1' => 'Erweiterungsattribut 1 (lokal)',
|
||||
'onPremisesExtensionAttributes.extensionAttribute2' => 'Erweiterungsattribut 2 (lokal)',
|
||||
'onPremisesExtensionAttributes.extensionAttribute3' => 'Erweiterungsattribut 3 (lokal)',
|
||||
'onPremisesExtensionAttributes.extensionAttribute4' => 'Erweiterungsattribut 4 (lokal)',
|
||||
'onPremisesExtensionAttributes.extensionAttribute5' => 'Erweiterungsattribut 5 (lokal)',
|
||||
'onPremisesExtensionAttributes.extensionAttribute6' => 'Erweiterungsattribut 6 (lokal)',
|
||||
'onPremisesExtensionAttributes.extensionAttribute7' => 'Erweiterungsattribut 7 (lokal)',
|
||||
'onPremisesExtensionAttributes.extensionAttribute8' => 'Erweiterungsattribut 8 (lokal)',
|
||||
'onPremisesExtensionAttributes.extensionAttribute9' => 'Erweiterungsattribut 9 (lokal)',
|
||||
'onPremisesExtensionAttributes.extensionAttribute10' => 'Erweiterungsattribut 10 (lokal)',
|
||||
'onPremisesExtensionAttributes.extensionAttribute11' => 'Erweiterungsattribut 11 (lokal)',
|
||||
'onPremisesExtensionAttributes.extensionAttribute12' => 'Erweiterungsattribut 12 (lokal)',
|
||||
'onPremisesExtensionAttributes.extensionAttribute13' => 'Erweiterungsattribut 13 (lokal)',
|
||||
'onPremisesExtensionAttributes.extensionAttribute14' => 'Erweiterungsattribut 14 (lokal)',
|
||||
'onPremisesExtensionAttributes.extensionAttribute15' => 'Erweiterungsattribut 15 (lokal)',
|
||||
];
|
||||
|
||||
/** Erlaubte Schreibweise eines Attributpfads. */
|
||||
public const PATH_PATTERN = '/^[A-Za-z][A-Za-z0-9_]*(\.[A-Za-z0-9_]+)*$/';
|
||||
|
||||
/**
|
||||
* $select für /me, /users/{id} und /users/delta.
|
||||
*/
|
||||
public static function select(IdentityProvider $provider): string
|
||||
{
|
||||
$top = array_map(fn (string $path) => self::topLevel($path), array_values($provider->attributeMap()));
|
||||
|
||||
return implode(',', array_values(array_unique([...self::BASE_SELECT, ...$top])));
|
||||
}
|
||||
|
||||
public static function topLevel(string $path): string
|
||||
{
|
||||
return explode('.', $path, 2)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Wert eines Attributpfads als Text. Listen werden mit Komma verbunden,
|
||||
* Wahrheitswerte als „Ja“/„Nein“ ausgegeben; leere Werte ergeben null.
|
||||
*
|
||||
* @param array<string, mixed> $graphUser
|
||||
*/
|
||||
public static function value(array $graphUser, string $path): ?string
|
||||
{
|
||||
$value = $graphUser;
|
||||
|
||||
foreach (explode('.', $path) as $segment) {
|
||||
if (! is_array($value) || ! array_key_exists($segment, $value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$value = $value[$segment];
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
$value = implode(', ', array_filter(Arr::flatten($value), fn ($v) => is_scalar($v) && $v !== ''));
|
||||
} elseif (is_bool($value)) {
|
||||
$value = $value ? 'Ja' : 'Nein';
|
||||
}
|
||||
|
||||
$value = is_scalar($value) ? trim((string) $value) : '';
|
||||
|
||||
return $value === '' ? null : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vorschlagsliste fürs Formular: häufige Attribute plus geladene Verzeichniserweiterungen.
|
||||
*
|
||||
* @return array<string, string> Pfad => Beschreibung
|
||||
*/
|
||||
public static function suggestions(?IdentityProvider $provider): array
|
||||
{
|
||||
$extensions = collect((array) $provider?->setting('extension_properties', []))
|
||||
->mapWithKeys(fn ($name) => [(string) $name => 'Verzeichniserweiterung'])
|
||||
->all();
|
||||
|
||||
return self::COMMON + $extensions;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue