There are 2 entry points installed in my system
- Microsoft Azure AD
- Keycloak
Role processing conditions are enabled. If you log in through Keycloak, everything works fine, if through Microsoft Azure AD, then an error:
Error: Call to undefined method Drupal\openid_connect_windows_aad\Plugin\OpenIDConnectClient\WindowsAad::applyRoleRules() in keycloak_openid_connect_userinfo_save() (line 70 of modules/contrib/keycloak/keycloak.module).
I checked the code in keycloak.module and added a role verification condition.
Before:
function keycloak_openid_connect_userinfo_save(UserInterface $account, array $context) {
$openid_connect_client = \Drupal::entityTypeManager()->getStorage('openid_connect_client')->load($context['plugin_id']);
if (!$openid_connect_client instanceof OpenIDConnectClientEntityInterface) {
return;
}
$openid_connect_client->getPlugin()->applyRoleRules($account, $context['userinfo']);
}
After:
function keycloak_openid_connect_userinfo_save(UserInterface $account, array $context) {
$openid_connect_client = \Drupal::entityTypeManager()->getStorage('openid_connect_client')->load($context['plugin_id']);
if (!$openid_connect_client instanceof OpenIDConnectClientEntityInterface) {
return;
}
// Get plugin
$plugin = $openid_connect_client->getPlugin();
// ะกheck the existence of the applyRuleRules method before calling
if (method_exists($plugin, 'applyRoleRules')) {
$plugin->applyRoleRules($account, $context['userinfo']);
} else {
\Drupal::logger('keycloak')->warning('The method applyRoleRules does not exist in the plugin: @plugin', ['@plugin' => $context['plugin_id']]);
}
}
Now its working. Check it out.