Error: Error: Call to undefined method Drupal\openid_connect_windows_aad\Plugin\OpenIDConnectClient\WindowsAad::applyRoleRules() in keycloak_openid_connect_userinfo_save() - line 70

Created on 20 June 2024, 9 months ago

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 key clock.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.

๐Ÿ› Bug report
Status

Active

Version

2.2

Component

Code

Created by

๐Ÿ‡ท๐Ÿ‡บRussia antiden

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024