File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4444 <?= $ this ->form ->text ('oauth2_key_groups ' , $ values ) ?>
4545 <p class="form-help"><?= t ('Leave empty, when no group mapping is wanted ' ) ?> </p>
4646
47+ <?= $ this ->form ->label (t ('Group Filter ' ), 'oauth2_key_group_filter ' ) ?>
48+ <?= $ this ->form ->text ('oauth2_key_group_filter ' , $ values ) ?>
49+ <p class="form-help"><?= t ('Use a comma to enter multiple useable groups: group1,group2 ' ) ?> </p>
50+
4751 <div class="form-actions">
4852 <input type="submit" value="<?= t ('Save ' ) ?> " class="btn btn-blue"/>
4953 </div>
Original file line number Diff line number Diff line change @@ -146,6 +146,27 @@ public function getEmail()
146146 return $ this ->getKey ('oauth2_key_email ' );
147147 }
148148
149+ /**
150+ * Check if group is in filter
151+ *
152+ * @access protected
153+ * @param string $group
154+ * @return boolean
155+ */
156+ protected function isGroupInFilter (string $ group , array $ filter )
157+ {
158+ if (empty ($ filter )) {
159+ $ this ->logger ->debug ('OAuth2: No group specified in filter. All provided groups will be used. ' );
160+ return true ;
161+ } else {
162+ if (in_array ($ group , $ filter )) {
163+ return true ;
164+ } else {
165+ return false ;
166+ }
167+ }
168+ }
169+
149170 /**
150171 * Get external group ids
151172 *
@@ -173,11 +194,19 @@ public function getExternalGroupIds()
173194 $ groups = array_unique ($ groups );
174195 $ this ->logger ->debug ('OAuth2: ' .$ this ->getUsername ().' groups are ' . join (', ' , $ groups ));
175196
197+ $ filteredGroups = array ();
198+ $ groupFilter = explode (', ' ,$ this ->configModel ->get ('oauth2_key_group_filter ' ));
199+
176200 foreach ($ groups as $ group ) {
177- $ this ->groupModel ->getOrCreateExternalGroupId ($ group , $ group );
201+ if ( $ this ->isGroupInFilter ($ group , $ groupFilter )) {
202+ $ this ->groupModel ->getOrCreateExternalGroupId ($ group , $ group );
203+ array_push ($ filteredGroups , $ group );
204+ } else {
205+ $ this ->logger ->debug ('OAuth2: ' .$ group .' will be ignored. ' );
206+ }
178207 }
179208
180- return $ groups ;
209+ return $ filteredGroups ;
181210 }
182211
183212 /**
You can’t perform that action at this time.
0 commit comments