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

Commit 3b23849

Browse files
Gaeldrinvyskocilpavel
authored andcommitted
added logic for inputting attributes into arrays
PerunAttributes filter did not allow assigning of one LDAP reply into multiple attributes on SP side. This is now handled by implicitly converting target attributes into array (even if there is only one) and changing the subsequent logic to handle arrays. Signed-off-by: Petr Vsetecka <[email protected]> Signed-off-by: Pavel Vyskočil <[email protected]>
1 parent 5969a36 commit 3b23849

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ All notable changes to this project will be documented in this file.
44
## [Unreleased]
55
[Added]
66
- List of services is displayed as JSON if parameter 'output=json' is set in URL
7-
7+
88
[Fixed]
99
- Fixed the problem where LDAP calls RPC method in PerunIdentity filter
10+
- Fixed assignation of one Perun attribute to multiple SP attributes
1011

1112
## [v2.1.0]
1213
[Added]

lib/Auth/Process/PerunAttributes.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function process(&$request)
6363

6464
$sspAttr = $this->attrMap[$attrName];
6565

66+
// convert $attrValue into array
6667
if (is_null($attrValue)) {
6768
$value = array();
6869
} else if (is_string($attrValue)) {
@@ -76,10 +77,24 @@ public function process(&$request)
7677
"Attribute name: $attrName, Supported types: null, string, array, associative array.");
7778
}
7879

80+
// convert $sspAttr into array
81+
if (is_string($sspAttr)) {
82+
$attrArray = array($sspAttr);
83+
} else if (is_array($sspAttr)) {
84+
$attrArray = $sspAttr;
85+
} else {
86+
throw new SimpleSAML_Error_Exception("sspmod_perun_Auth_Process_PerunAttributes - Unsupported attribute type. ".
87+
"Attribute \$attrName, Supported types: string, array.");
88+
}
89+
7990
SimpleSAML\Logger::debug("perun:PerunAttributes: perun attribute $attrName was fetched. " .
80-
"Value ".implode(",", $value)." is being set to ssp attribute $sspAttr");
91+
"Value " . implode(",", $value) . " is being set to ssp attribute " . implode(",", $attrArray));
92+
93+
// write $value to all SP attributes
94+
foreach ($attrArray as $attribute) {
95+
$request['Attributes'][$attribute] = $value;
96+
}
8197

82-
$request['Attributes'][$sspAttr] = $value;
8398
}
8499

85100
}

0 commit comments

Comments
 (0)