Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit 6e4ab10

Browse files
authored
Merge pull request #2 from CESNET/eduPersonEntitlement
Added optional attribute groupNamePrefix.
2 parents 658d95d + bc22842 commit 6e4ab10

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

lib/Auth/Process/PerunGroups.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@
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
*/
1214
class 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

Comments
 (0)