You are here

public function KeycloakRoleMatcher::getRoleRules in Keycloak OpenID Connect 8

Return the Keycloak role rules.

Parameters

bool $enabled_only: (Optional) Whether to return enabled rules only. Defaults to FALSE.

Return value

array Array of role rules. Each rule is an associative array with the following keys:

  • id: (Internal) ID of the rule.
  • weight: The weight of the rule.
  • role: Drupal role ID this rule applies to.
  • action: Action to take, if the rule matches.
  • operation: Rule matching operation.
  • pattern: Value to evaluate.
  • case_sensitive: Whether the pattern must match case-sensitive.
  • enabled: Whether the rule is enabled.
1 call to KeycloakRoleMatcher::getRoleRules()
KeycloakRoleMatcher::applyRoleRules in src/Service/KeycloakRoleMatcher.php
Applies user role rules to the given user account.

File

src/Service/KeycloakRoleMatcher.php, line 100

Class

KeycloakRoleMatcher
Role matcher service.

Namespace

Drupal\keycloak\Service

Code

public function getRoleRules($enabled_only = FALSE) {
  $rules = $this->config
    ->get('settings.keycloak_groups.rules');

  // Make sure we return an array.
  if (empty($rules)) {
    $rules = [];
  }
  elseif ($enabled_only) {
    $rules = array_filter($rules, function ($rule) {
      return $rule['enabled'];
    });
  }
  return $rules;
}