Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m37s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m41s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m40s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m42s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 2m10s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 2m6s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 1m55s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m2s
CI / Build-Artefakte aktuell (pull_request) Successful in 52s
- OpenID Connect mit PKCE, State und Nonce; ID-Token-Prüfung gegen die Microsoft-Schlüssel (Signatur, Mandant, App, Gültigkeit, Nonce) inkl. Neuladen bei Schlüsselwechsel - Konto bei erster Anmeldung anlegen oder per E-Mail verknüpfen, optionale Domain-Beschränkung, deaktivierte Konten bleiben gesperrt - Gruppen (inkl. Overage über Graph, transitiv) und App-Rollen → Rollen, additiv; nur Zuweisungen aus Entra werden abgeglichen, manuelle bleiben - Profilfelder, Vorgesetzte*r und Profilfoto aus Graph, je Feld wählbar und im Portal schreibgeschützt; Fallback auf Token-Angaben, wenn Graph ausfällt - Hintergrund-Abgleich mit Delta-Abfragen (Zeitbudget, Fortsetzung über nextLink/deltaLink), Offboarding deaktivierter/gelöschter Konten, optionale Vorab-Anlage, Fotos/Vorgesetzte rollierend, Gruppen und App-Rollen stündlich - Admin „Anmeldung“: Einrichtung mit Umleitungs-URI und Berechtigungen, verschlüsseltes Geheimnis (nie im Browser), Gruppensuche, Status, „Mapping testen“ - Fix: @odata.nextLink/@odata.deltaLink wurden als Pfad gelesen – Folgeseiten fehlten - Profilseite mit Vorgesetzter/m und Mitarbeitenden; Version 0.4.0 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
53 lines
2 KiB
PHP
53 lines
2 KiB
PHP
<?php
|
|
|
|
namespace App\Identity\Entra;
|
|
|
|
/**
|
|
* Normalisiert Entra-/Graph-Benutzerdaten auf die Profilfelder des Portals.
|
|
*/
|
|
final class EntraProfile
|
|
{
|
|
/** Felder, die bei Graph abgefragt werden. */
|
|
public const SELECT = 'id,displayName,givenName,surname,mail,userPrincipalName,jobTitle,department,officeLocation,businessPhones,mobilePhone,accountEnabled,userType';
|
|
|
|
/**
|
|
* @param array<string, mixed> $graphUser Antwort von /me bzw. /users/{id}
|
|
* @return array<string, mixed>
|
|
*/
|
|
public static function fromGraph(array $graphUser, ?string $managerSubject = null, bool $withManager = false): array
|
|
{
|
|
$profile = [
|
|
'display_name' => $graphUser['displayName'] ?? null,
|
|
'first_name' => $graphUser['givenName'] ?? null,
|
|
'last_name' => $graphUser['surname'] ?? null,
|
|
'email' => $graphUser['mail'] ?? (str_contains((string) ($graphUser['userPrincipalName'] ?? ''), '#EXT#') ? null : ($graphUser['userPrincipalName'] ?? null)),
|
|
'job_title' => $graphUser['jobTitle'] ?? null,
|
|
'department' => $graphUser['department'] ?? null,
|
|
'location' => $graphUser['officeLocation'] ?? null,
|
|
'phone' => $graphUser['businessPhones'][0] ?? null,
|
|
'mobile' => $graphUser['mobilePhone'] ?? null,
|
|
];
|
|
|
|
if ($withManager) {
|
|
$profile['manager_subject'] = $managerSubject;
|
|
}
|
|
|
|
return $profile;
|
|
}
|
|
|
|
/**
|
|
* Rückfall, wenn Graph nicht erreichbar ist: Angaben aus dem ID-Token.
|
|
*
|
|
* @param array<string, mixed> $claims
|
|
* @return array<string, mixed>
|
|
*/
|
|
public static function fromClaims(array $claims): array
|
|
{
|
|
return [
|
|
'display_name' => $claims['name'] ?? null,
|
|
'first_name' => $claims['given_name'] ?? null,
|
|
'last_name' => $claims['family_name'] ?? null,
|
|
'email' => $claims['email'] ?? $claims['preferred_username'] ?? null,
|
|
];
|
|
}
|
|
}
|