fix: [keycloak status] - handle gracefully if user not found in KC

- As reported by Matúš Mikuláš, Adam Gajdošík, Milan Pikula of SK-CERT
develop-unstable
iglocska 2023-01-03 15:41:09 +01:00
parent a5eb016fc4
commit 13bb031167
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 11 additions and 1 deletions

View File

@ -455,7 +455,17 @@ class AuthKeycloakBehavior extends Behavior
$user['meta_fields'] = $temp;
$differences = [];
$keycloakUser = $keycloakUsersParsed[$username] ?? [];
$requireUpdate = $this->checkKeycloakUserRequiresUpdate($keycloakUser, $user, $differences);
if (empty($keycloakUser)) {
$requireUpdate = true;
$differences = [
'user' => [
'keycloak' => 'USER NOT FOUND',
'cerebrate' => $user['username']
]
];
} else {
$requireUpdate = $this->checkKeycloakUserRequiresUpdate($keycloakUser, $user, $differences);
}
$status[$user['id']] = [
'require_update' => $requireUpdate,
'differences' => $differences,