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

Commit 43caf5f

Browse files
committed
Added optional attribute groupNamePrefix.
It allows to set prefix and follow recommendations of AARC for group membership expression.
1 parent 6e4ab10 commit 43caf5f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/Auth/Process/PerunGroups.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
class sspmod_perun_Auth_Process_PerunGroups extends SimpleSAML_Auth_ProcessingFilter
1515
{
1616

17+
const GROUPNAMEPREFIX_ATTR = 'groupNamePrefix';
18+
1719
private $attrName;
1820
private $groupNamePrefix;
1921

@@ -28,11 +30,11 @@ public function __construct($config, $reserved)
2830
}
2931
$this->attrName = (string) $config['attrName'];
3032

31-
if (!isset($config['groupNamePrefix'])) {
32-
SimpleSAML_Logger::warning("perun:PerunGroups: optional attribute 'groupNamePrefix' missing, assuming empty prefix");
33+
if (!isset($config[GROUPNAMEPREFIX_ATTR])) {
34+
SimpleSAML_Logger::warning("perun:PerunGroups: optional attribute '". GROUPNAMEPREFIX_ATTR . "' is missing, assuming empty prefix");
3335
$this->groupNamePrefix = '';
3436
} else {
35-
$this->groupNamePrefix = (string) $config['groupNamePrefix'];
37+
$this->groupNamePrefix = (string) $config[GROUPNAMEPREFIX_ATTR];
3638
}
3739
}
3840

@@ -68,6 +70,9 @@ protected function mapGroupName($request, $groupName) {
6870
if (isset($request["SPMetadata"]["groupMapping"]) && isset($request["SPMetadata"]["groupMapping"][$groupName])) {
6971
SimpleSAML_Logger::debug("Mapping $groupName to " . $request["SPMetadata"]["groupMapping"][$groupName] . " for SP " . $request["SPMetadata"]["entityid"]);
7072
return $request["SPMetadata"]["groupMapping"][$groupName];
73+
} else if (isset($request["SPMetadata"][GROUPNAMEPREFIX_ATTR])) {
74+
SimpleSAML_Logger::debug("GroupNamePrefix overridden by a SP " . $request["SPMetadata"]["entityid"] . " to " . $request["SPMetadata"][GROUPNAMEPREFIX_ATTR]);
75+
return $request["SPMetadata"][GROUPNAMEPREFIX_ATTR] . $groupName;
7176
} else {
7277
# No mapping defined, so just put groupNamePrefix in front of the group
7378
SimpleSAML_Logger::debug("No mapping found for group $groupName for SP " . $request["SPMetadata"]["entityid"]);

0 commit comments

Comments
 (0)