Add a null check to ClientModels loaded by ID from ClientPolicyRepresentation.

Closes #37673

Signed-off-by: Garth <244253+xgp@users.noreply.github.com>
This commit is contained in:
Garth
2025-02-26 22:56:06 +01:00
committed by Pedro Igor
parent 3f7a1ee5a6
commit e0806c6284

View File

@@ -30,11 +30,12 @@ public class ClientPolicyProvider implements PolicyProvider {
for (String client : representation.getClients()) {
ClientModel clientModel = realm.getClientById(client);
if (context.getAttributes().containsValue("kc.client.id", clientModel.getClientId())) {
evaluation.grant();
logger.debugf("Client policy %s matched with client %s and was granted", evaluation.getPolicy().getName(), clientModel.getClientId());
return;
if (clientModel != null) {
if (context.getAttributes().containsValue("kc.client.id", clientModel.getClientId())) {
evaluation.grant();
logger.debugf("Client policy %s matched with client %s and was granted", evaluation.getPolicy().getName(), clientModel.getClientId());
return;
}
}
}
}