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
91
tests/Support/FakeLdap.php
Normal file
91
tests/Support/FakeLdap.php
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Support;
|
||||
|
||||
use Inhaus\Plugins\Ldap\Connection\LdapConnection;
|
||||
use Inhaus\Plugins\Ldap\Connection\LdapConnector;
|
||||
use Inhaus\Plugins\Ldap\LdapDirectory;
|
||||
|
||||
/**
|
||||
* Simuliertes Verzeichnis: Einträge mit Passwörtern, Gruppen je Person.
|
||||
* Die Suche wertet nur „(attribut=wert)“-Paare aus – genug, um Filter und
|
||||
* Maskierung zu prüfen.
|
||||
*/
|
||||
class FakeLdap implements LdapConnection, LdapConnector
|
||||
{
|
||||
/** @var array<string, array{password: ?string, attributes: array<string, list<string>>}> DN => Eintrag */
|
||||
public array $entries = [];
|
||||
|
||||
/** @var array<string, list<string>> Personen-DN => Gruppen-DNs (verschachtelte Suche) */
|
||||
public array $nestedGroups = [];
|
||||
|
||||
/** @var list<string> */
|
||||
public array $filters = [];
|
||||
|
||||
/** @var list<?string> */
|
||||
public array $binds = [];
|
||||
|
||||
public array $lastOptions = [];
|
||||
|
||||
public function connect(array $options): LdapConnection
|
||||
{
|
||||
$this->lastOptions = $options;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function add(string $dn, ?string $password, array $attributes): void
|
||||
{
|
||||
$this->entries[$dn] = ['password' => $password, 'attributes' => array_change_key_case(array_map(fn ($v) => (array) $v, $attributes))];
|
||||
}
|
||||
|
||||
public function bind(?string $dn, ?string $password): bool
|
||||
{
|
||||
$this->binds[] = $dn;
|
||||
|
||||
if ($dn === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isset($this->entries[$dn]) && $this->entries[$dn]['password'] !== null && $password !== '' && hash_equals($this->entries[$dn]['password'], (string) $password);
|
||||
}
|
||||
|
||||
public function search(string $base, string $filter, array $attributes, int $limit = 0): array
|
||||
{
|
||||
$this->filters[] = $filter;
|
||||
|
||||
if (str_contains($filter, 'member:1.2.840.113556.1.4.1941:=')) {
|
||||
foreach ($this->nestedGroups as $dn => $groups) {
|
||||
if (str_contains($filter, '='.LdapDirectory::escape($dn).')')) {
|
||||
return array_map(fn ($g) => ['dn' => $g, 'attributes' => []], $groups);
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
$found = [];
|
||||
|
||||
foreach ($this->entries as $dn => $entry) {
|
||||
foreach (['samaccountname', 'userprincipalname', 'mail', 'uid'] as $attribute) {
|
||||
foreach ($entry['attributes'][$attribute] ?? [] as $value) {
|
||||
if (preg_match('/\('.$attribute.'='.preg_quote(LdapDirectory::escape($value), '/').'\)/i', $filter)) {
|
||||
$found[$dn] = ['dn' => $dn, 'attributes' => $entry['attributes']];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($found);
|
||||
}
|
||||
|
||||
public function read(string $dn, array $attributes): ?array
|
||||
{
|
||||
return isset($this->entries[$dn]) ? ['dn' => $dn, 'attributes' => $this->entries[$dn]['attributes']] : null;
|
||||
}
|
||||
|
||||
public function lastError(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue