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>
99 lines
2.7 KiB
PHP
99 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* Ein angebundener Identity Provider (zunächst Microsoft Entra ID).
|
|
*
|
|
* config (verschlüsselt): tenant_id, client_id, client_secret, button_label,
|
|
* auto_provision, link_by_email, allowed_domains, default_role_id,
|
|
* synced_fields, sync_photo, directory_sync, directory_create_users
|
|
*/
|
|
#[Fillable(['type', 'name', 'slug', 'enabled', 'config'])]
|
|
class IdentityProvider extends Model
|
|
{
|
|
public const ENTRA = 'entra';
|
|
|
|
/** Profilfelder, die aus dem Identity Provider übernommen werden können. */
|
|
public const SYNCABLE_FIELDS = [
|
|
'first_name' => 'Vorname',
|
|
'last_name' => 'Nachname',
|
|
'email' => 'E-Mail-Adresse',
|
|
'job_title' => 'Funktion',
|
|
'department' => 'Abteilung',
|
|
'location' => 'Standort',
|
|
'phone' => 'Telefon',
|
|
'mobile' => 'Mobil',
|
|
'manager' => 'Vorgesetzte*r',
|
|
];
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::saving(function (IdentityProvider $provider) {
|
|
$provider->slug = $provider->slug ?: Str::slug($provider->name) ?: $provider->type;
|
|
});
|
|
}
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'enabled' => 'boolean',
|
|
'config' => 'encrypted:array',
|
|
];
|
|
}
|
|
|
|
public function setting(string $key, mixed $default = null): mixed
|
|
{
|
|
return data_get($this->config, $key, $default);
|
|
}
|
|
|
|
/**
|
|
* @return list<string>
|
|
*/
|
|
public function syncedFields(): array
|
|
{
|
|
return array_values(array_intersect((array) $this->setting('synced_fields', []), array_keys(self::SYNCABLE_FIELDS)));
|
|
}
|
|
|
|
public function buttonLabel(): string
|
|
{
|
|
return $this->setting('button_label') ?: 'Mit Microsoft anmelden';
|
|
}
|
|
|
|
public function isEmailDomainAllowed(?string $email): bool
|
|
{
|
|
$domains = array_filter(array_map(fn ($d) => strtolower(trim((string) $d)), (array) $this->setting('allowed_domains', [])));
|
|
|
|
if ($domains === []) {
|
|
return true;
|
|
}
|
|
|
|
return $email !== null && in_array(strtolower(substr(strrchr($email, '@') ?: '', 1)), $domains, true);
|
|
}
|
|
|
|
public function sourcePrefix(): string
|
|
{
|
|
return $this->id.':';
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<IdpGroupMapping, $this>
|
|
*/
|
|
public function mappings(): HasMany
|
|
{
|
|
return $this->hasMany(IdpGroupMapping::class);
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<UserIdentity, $this>
|
|
*/
|
|
public function identities(): HasMany
|
|
{
|
|
return $this->hasMany(UserIdentity::class);
|
|
}
|
|
}
|