Skip to content

Commit bf8f2dd

Browse files
authored
Merge pull request #6003 from AngelFQC/BT21930-2
Plugin: Azure: Add option to filter groups by display name
2 parents 2485899 + 38d8bce commit bf8f2dd

File tree

6 files changed

+18
-0
lines changed

6 files changed

+18
-0
lines changed

plugin/azure_active_directory/lang/dutch.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,5 @@
5050
$strings['script_users_delta_help'] = 'Get newly created, updated, or deleted users without having to perform a full read of the entire user collection. By default, is <code>No</code>.';
5151
$strings['script_usergroups_delta'] = 'Delta query for usergroups';
5252
$strings['script_usergroups_delta_help'] = 'Get newly created, updated, or deleted groups, including group membership changes, without having to perform a full read of the entire group collection. By default, is <code>No</code>.';
53+
$strings['group_filter_regex'] = 'Group filter RegEx';
54+
$strings['group_filter_regex_help'] = 'Regular expression to filter groups (only matches will be synchronized), e.g. <code>.*-FIL-.*</code> <code>.*-PAR-.*</code> <code>.*(FIL|PAR).*</code> <code>^(FIL|PAR).*</code>';

plugin/azure_active_directory/lang/english.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,5 @@
5050
$strings['script_users_delta_help'] = 'Get newly created, updated, or deleted users without having to perform a full read of the entire user collection. By default, is <code>No</code>.';
5151
$strings['script_usergroups_delta'] = 'Delta query for usergroups';
5252
$strings['script_usergroups_delta_help'] = 'Get newly created, updated, or deleted groups, including group membership changes, without having to perform a full read of the entire group collection. By default, is <code>No</code>.';
53+
$strings['group_filter_regex'] = 'Group filter RegEx';
54+
$strings['group_filter_regex_help'] = 'Regular expression to filter groups (only matches will be synchronized), e.g. <code>.*-FIL-.*</code> <code>.*-PAR-.*</code> <code>.*(FIL|PAR).*</code> <code>^(FIL|PAR).*</code>';

plugin/azure_active_directory/lang/french.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,5 @@
5050
$strings['script_users_delta_help'] = 'Get newly created, updated, or deleted users without having to perform a full read of the entire user collection. By default, is <code>No</code>.';
5151
$strings['script_usergroups_delta'] = 'Requête delta pour les groupes d\'utilisateurs';
5252
$strings['script_usergroups_delta_help'] = 'Get newly created, updated, or deleted groups, including group membership changes, without having to perform a full read of the entire group collection. By default, is <code>No</code>.';
53+
$strings['group_filter_regex'] = 'Group filter RegEx';
54+
$strings['group_filter_regex_help'] = 'Regular expression to filter groups (only matches will be synchronized), e.g. <code>.*-FIL-.*</code> <code>.*-PAR-.*</code> <code>.*(FIL|PAR).*</code> <code>^(FIL|PAR).*</code>';

plugin/azure_active_directory/lang/spanish.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,5 @@
5050
$strings['script_users_delta_help'] = 'Obtiene usuarios recién creados, actualizados o eliminados sin tener que realizar una lectura completa de toda la colección de usuarios. De forma predeterminada, es <code>No</code>.';
5151
$strings['script_usergroups_delta'] = 'Consulta delta para grupos de usuarios';
5252
$strings['script_usergroups_delta_help'] = 'Obtiene grupos recién creados, actualizados o eliminados, incluidos los cambios de membresía del grupo, sin tener que realizar una lectura completa de toda la colección de grupos. De forma predeterminada, es <code>No</code>';
53+
$strings['group_filter_regex'] = 'Group filter RegEx';
54+
$strings['group_filter_regex_help'] = 'Expresión regular para filtrar grupos (solo las coincidencias serán sincronizadas), p.ej. <code>.*-FIL-.*</code> <code>.*-PAR-.*</code> <code>.*(FIL|PAR).*</code> <code>^(FIL|PAR).*</code>';

plugin/azure_active_directory/src/AzureActiveDirectory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class AzureActiveDirectory extends Plugin
3333
public const SETTING_DEACTIVATE_NONEXISTING_USERS = 'deactivate_nonexisting_users';
3434
public const SETTING_GET_USERS_DELTA = 'script_users_delta';
3535
public const SETTING_GET_USERGROUPS_DELTA = 'script_usergroups_delta';
36+
public const SETTING_GROUP_FILTER = 'group_filter_regex';
3637

3738
public const URL_TYPE_AUTHORIZE = 'login';
3839
public const URL_TYPE_LOGOUT = 'logout';
@@ -66,6 +67,7 @@ protected function __construct()
6667
self::SETTING_DEACTIVATE_NONEXISTING_USERS => 'boolean',
6768
self::SETTING_GET_USERS_DELTA => 'boolean',
6869
self::SETTING_GET_USERGROUPS_DELTA => 'boolean',
70+
self::SETTING_GROUP_FILTER => 'text',
6971
];
7072

7173
parent::__construct('2.5', 'Angel Fernando Quiroz Campos, Yannick Warnier', $settings);

plugin/azure_active_directory/src/AzureCommand.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ protected function getAzureUsers(): Generator
121121
*/
122122
protected function getAzureGroups(): Generator
123123
{
124+
$groupFilter = $this->plugin->get(AzureActiveDirectory::SETTING_GROUP_FILTER);
125+
124126
$groupFields = [
125127
'id',
126128
'displayName',
@@ -161,6 +163,12 @@ protected function getAzureGroups(): Generator
161163
$azureGroupsInfo = $azureGroupsRequest['value'] ?? [];
162164

163165
foreach ($azureGroupsInfo as $azureGroupInfo) {
166+
if (!empty($groupFilter) &&
167+
!preg_match("/$groupFilter/", $azureGroupInfo['displayName'])
168+
) {
169+
continue;
170+
}
171+
164172
yield $azureGroupInfo;
165173
}
166174

0 commit comments

Comments
 (0)