33/**
44 * Class sspmod_perun_Auth_Process_PerunGroups
55 *
6- * This filter extracts group names from cached groups from PerunIdentity filter and save them into attribute.
7- * It means it strongly relays on it.
8- * It also translates (renames) given name of group based on associative array 'groupMapping' in SP metadata.
6+ * This filter extracts group names from cached groups from PerunIdentity filter and save them into attribute defined by attrName.
7+ * By default attribute value will be filled with the groupNamePrefix + groupName.
8+ *
9+ * It is also capable of translation of (renames) group names using 'groupMapping' attribute in SP metadata.
910 *
1011 * @author Ondrej Velisek <[email protected] > 12+ * @author Michal Prochazka <[email protected] > 1113 */
1214class sspmod_perun_Auth_Process_PerunGroups extends SimpleSAML_Auth_ProcessingFilter
1315{
1416
1517 private $ attrName ;
18+ private $ groupNamePrefix ;
1619
1720 public function __construct ($ config , $ reserved )
1821 {
@@ -24,6 +27,13 @@ public function __construct($config, $reserved)
2427 throw new SimpleSAML_Error_Exception ("perun:PerunGroups: missing mandatory configuration option 'attrName'. " );
2528 }
2629 $ this ->attrName = (string ) $ config ['attrName ' ];
30+
31+ if (!isset ($ config ['groupNamePrefix ' ])) {
32+ SimpleSAML_Logger::warning ("perun:PerunGroups: optional attribute 'groupNamePrefix' missing, assuming empty prefix " );
33+ $ this ->groupNamePrefix = '' ;
34+ } else {
35+ $ this ->groupNamePrefix = (string ) $ config ['groupNamePrefix ' ];
36+ }
2737 }
2838
2939
@@ -59,9 +69,9 @@ protected function mapGroupName($request, $groupName) {
5969 SimpleSAML_Logger::debug ("Mapping $ groupName to " . $ request ["SPMetadata " ]["groupMapping " ][$ groupName ] . " for SP " . $ request ["SPMetadata " ]["entityid " ]);
6070 return $ request ["SPMetadata " ]["groupMapping " ][$ groupName ];
6171 } else {
62- # No mapping defined
72+ # No mapping defined, so just put groupNamePrefix in front of the group
6373 SimpleSAML_Logger::debug ("No mapping found for group $ groupName for SP " . $ request ["SPMetadata " ]["entityid " ]);
64- return $ groupName ;
74+ return $ this -> groupNamePrefix . $ groupName ;
6575 }
6676 }
6777
0 commit comments