1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-09 10:22:51 +03:00

OIDC: Fixed incorrect detection of group detail population

An empty (but valid formed) groups list provided via the OIDC ID token
would be considered as a lacking detail, and therefore trigger a lookup
to the userinfo endpoint in an attempt to get that information.

This fixes this to properly distinguish between not-provided and empty
state, to avoid userinfo where provided as valid but empty.

Includes test to cover.
For #5101
This commit is contained in:
Dan Brown
2024-07-14 14:21:16 +01:00
parent 7161f22706
commit 767699a066
2 changed files with 24 additions and 4 deletions

View File

@@ -22,7 +22,7 @@ class OidcUserDetails
$hasEmpty = empty($this->externalId)
|| empty($this->email)
|| empty($this->name)
|| ($groupSyncActive && empty($this->groups));
|| ($groupSyncActive && $this->groups === null);
return !$hasEmpty;
}
@@ -57,15 +57,15 @@ class OidcUserDetails
return implode(' ', $displayName);
}
protected static function getUserGroups(string $groupsClaim, ProvidesClaims $token): array
protected static function getUserGroups(string $groupsClaim, ProvidesClaims $token): ?array
{
if (empty($groupsClaim)) {
return [];
return null;
}
$groupsList = Arr::get($token->getAllClaims(), $groupsClaim);
if (!is_array($groupsList)) {
return [];
return null;
}
return array_values(array_filter($groupsList, function ($val) {