@@ -27,13 +27,15 @@ class sspmod_perun_Auth_Process_PerunIdentity extends SimpleSAML_Auth_Processing
2727 const CALLBACK_PARAM_NAME = 'callbackParamName ' ;
2828 const INTERFACE_PROPNAME = 'interface ' ;
2929 const SOURCE_IDP_ENTITY_ID_ATTR = 'sourceIdPEntityIDAttr ' ;
30+ const FORCE_REGISTRATION_TO_GROUPS = 'forceRegistrationToGroups ' ;
3031
3132 private $ uidAttr ;
3233 private $ registerUrl ;
3334 private $ voShortName ;
3435 private $ callbackParamName ;
3536 private $ interface ;
3637 private $ sourceIdPEntityIDAttr ;
38+ private $ forceRegistrationToGroups ;
3739
3840 /**
3941 * @var sspmod_perun_Adapter
@@ -63,13 +65,17 @@ public function __construct($config, $reserved)
6365 if (!isset ($ config [self ::SOURCE_IDP_ENTITY_ID_ATTR ])) {
6466 $ config [self ::SOURCE_IDP_ENTITY_ID_ATTR ] = sspmod_perun_Auth_Process_RetainIdPEntityID::DEFAULT_ATTR_NAME ;
6567 }
68+ if (!isset ($ config [self ::FORCE_REGISTRATION_TO_GROUPS ])) {
69+ $ config [self ::FORCE_REGISTRATION_TO_GROUPS ] = false ;
70+ }
6671
6772 $ this ->uidAttr = (string ) $ config [self ::UID_ATTR ];
6873 $ this ->registerUrl = (string ) $ config [self ::REGISTER_URL ];
6974 $ this ->voShortName = (string ) $ config [self ::VO_SHORTNAME ];
7075 $ this ->callbackParamName = (string ) $ config [self ::CALLBACK_PARAM_NAME ];
7176 $ this ->interface = (string ) $ config [self ::INTERFACE_PROPNAME ];
7277 $ this ->sourceIdPEntityIDAttr = $ config [self ::SOURCE_IDP_ENTITY_ID_ATTR ];
78+ $ this ->forceRegistrationToGroups = $ config [self ::FORCE_REGISTRATION_TO_GROUPS ];
7379 $ this ->adapter = sspmod_perun_Adapter::getInstance ($ this ->interface );
7480 }
7581
@@ -182,7 +188,7 @@ protected function register($request, $registerUrl, $callbackParamName, $vo, $gr
182188 $ stateId = SimpleSAML_Auth_State::saveState ($ request , 'perun:PerunIdentity ' );
183189 $ callback = SimpleSAML_Module::getModuleURL ('perun/perun_identity_callback.php ' , array ('stateId ' => $ stateId ));
184190
185- if ($ this ->containsGroupWithName ($ groups, ' members ' ) ) {
191+ if ($ this ->containsMembersGroup ($ groups) || $ this -> forceRegistrationToGroups === false ) {
186192 $ this ->registerDirectly ($ registerUrl , $ callbackParamName , $ callback , $ vo );
187193 }
188194 if (sizeof ($ groups ) === 1 ) {
@@ -276,14 +282,15 @@ private function containsId($entities, $value)
276282 }
277283
278284 /**
285+ * Returns true, if entities contains VO members group
286+ *
279287 * @param sspmod_perun_model_Group[] $entities
280- * @param string $name
281288 * @return bool
282289 */
283- private function containsGroupWithName ($ entities, $ name )
290+ private function containsMembersGroup ($ entities )
284291 {
285292 foreach ($ entities as $ entity ) {
286- if ($ entity ->getName () === $ name ) {
293+ if (preg_match ( ' /[^:]*:members$/ ' , $ entity ->getName ()) ) {
287294 return true ;
288295 }
289296 }
0 commit comments