Commit 404d5f6f authored by Diego Diestra's avatar Diego Diestra
Browse files

Issue #3294130 - Allow and condition on role

parent 62c8acfa
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -214,7 +214,13 @@ class AuthenticationService implements AuthenticationServiceInterface {

    $drupal_role_mappings = [];
    foreach ($available_roles as $role_machine_name => $role_nice_name) {
      $drupal_role_mappings[$role_machine_name] = explode(',', $this->configFactory->get('onelogin_integration.settings')->get('role_' . $role_machine_name));
      $role_groups = explode(',', $this->configFactory->get('onelogin_integration.settings')->get('role_' . $role_machine_name));

      foreach ($role_groups as $key => $role_group) {
        $role_groups[$key] = array_unique(explode('|', $role_group));
      }

      $drupal_role_mappings[$role_machine_name] = $role_groups;
    }

    // If the delimiter is set, split the string with the delimiter.
@@ -227,9 +233,9 @@ class AuthenticationService implements AuthenticationServiceInterface {
    }

    // Look at the mapped roles and assign those to the user.
    foreach ($saml_roles as $saml_role) {
    foreach ($drupal_role_mappings as $drupal_role => $mapping) {
        if (in_array($saml_role, $mapping)) {
      foreach ($mapping as $role_group) {
        if (count($role_group) == count(array_intersect($saml_roles, $role_group))) {
          $roles[] = $drupal_role;
        }
      }