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

Commit bbadc5f

Browse files
Merge pull request #52 from Gaeldrin/fix-PerunAttributes-mapping
Fix perun attributes mapping
2 parents 8a6f541 + 3b23849 commit bbadc5f

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
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: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function process(&$request)
5151
} else {
5252
throw new SimpleSAML_Error_Exception("perun:PerunAttributes: " .
5353
"missing mandatory field 'perun.user' in request." .
54-
"Hint: Did you configured PerunIdentity filter before this filter?"
54+
"Hint: Have you configured PerunIdentity filter before this filter?"
5555
);
5656
}
5757

@@ -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 setted 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)