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

Commit 4a0462c

Browse files
committed
Fixed getting attributes in class ForceAup
1 parent 2e9c3cc commit 4a0462c

File tree

3 files changed

+15
-22
lines changed

3 files changed

+15
-22
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
All notable changes to this project will be documented in this file.
33

44
## [Unreleased]
5+
#### Fixed
6+
- Fixed getting attributes in class ForceAup
57

68
## [v4.0.0]
79
#### Added

lib/AdapterRpc.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,8 @@ public function getUserAttributesValues($user, $attributes)
265265
public function getEntitylessAttribute($attrName)
266266
{
267267
$attributes = [];
268-
269268
$perunAttrValues = $this->connector->get('attributesManager', 'getEntitylessAttributes', [
270-
'attrName' => $attrName,
269+
'attrName' => AttributeUtils::getAttrName($attrName, self::RPC),
271270
]);
272271

273272
if (!isset($perunAttrValues[0]['id'])) {

lib/Auth/Process/ForceAup.php

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace SimpleSAML\Module\perun\Auth\Process;
44

5+
use SimpleSAML\Auth\ProcessingFilter;
56
use SimpleSAML\Error\Exception;
67
use SimpleSAML\Module\perun\Adapter;
7-
use SimpleSAML\Module\perun\AttributeUtils;
88
use SimpleSAML\Module\perun\model;
99
use SimpleSAML\Logger;
1010
use SimpleSAML\Auth\State;
@@ -27,24 +27,23 @@
2727
*
2828
* It relies on PerunIdentity filter. Configure it before this filter properly.
2929
*/
30-
class ForceAup extends \SimpleSAML\Auth\ProcessingFilter
30+
class ForceAup extends ProcessingFilter
3131
{
3232

3333
const UID_ATTR = 'uidAttr';
3434
const INTERFACE_PROPNAME = 'interface';
3535
const PERUN_AUPS_ATTR = 'perunAupsAttr';
3636
const PERUN_USER_AUP_ATTR = 'perunUserAupAttr';
3737
const PERUN_VO_AUP_ATTR = 'perunVoAupAttr';
38-
const PERUN_FACILITY_REQ_AUPS_ATTR = 'facilityReqAupsAttr';
39-
const PERUN_FACILITY_VO_SHORT_NAMES_ATTR = 'facilityVoShortNamesAttr';
38+
const PERUN_FACILITY_REQ_AUPS_ATTR = 'perunFacilityReqAupsAttr';
39+
const PERUN_FACILITY_VO_SHORT_NAMES_ATTR = 'perunFacilityVoShortNamesAttr';
4040

4141
private $uidAttr;
4242
private $perunAupsAttr;
4343
private $perunUserAupAttr;
4444
private $perunVoAupAttr;
4545
private $perunFacilityReqAupsAttr;
4646
private $perunFacilityVoShortNames;
47-
private $interface;
4847

4948
/**
5049
* @var Adapter
@@ -83,18 +82,11 @@ public function __construct($config, $reserved)
8382
$this->perunAupsAttr = (string)$config[self::PERUN_AUPS_ATTR];
8483
$this->perunUserAupAttr = (string)$config[self::PERUN_USER_AUP_ATTR];
8584
$this->perunVoAupAttr = (string)$config[self::PERUN_VO_AUP_ATTR];
86-
$this->interface = (string)$config[self::INTERFACE_PROPNAME];
87-
$this->adapter = Adapter::getInstance($this->interface);
88-
89-
$this->perunFacilityReqAupsAttr = AttributeUtils::getAttrName(
90-
self::PERUN_FACILITY_REQ_AUPS_ATTR,
91-
$this->interface
92-
);
93-
94-
$this->perunFacilityVoShortNames = AttributeUtils::getAttrName(
95-
self::PERUN_FACILITY_VO_SHORT_NAMES_ATTR,
96-
$this->interface
97-
);
85+
$interface = (string)$config[self::INTERFACE_PROPNAME];
86+
$this->adapter = Adapter::getInstance($interface);
87+
88+
$this->perunFacilityReqAupsAttr = (string)$config[self::PERUN_FACILITY_REQ_AUPS_ATTR];
89+
$this->perunFacilityVoShortNames = (string)$config[self::PERUN_FACILITY_VO_SHORT_NAMES_ATTR];
9890
}
9991

10092
/**
@@ -129,19 +121,19 @@ public function process(&$request)
129121

130122
$facilityAttrValues = $this->adapter->getFacilityAttributesValues(
131123
$facility,
132-
[self::PERUN_FACILITY_REQ_AUPS_ATTR, self::PERUN_FACILITY_VO_SHORT_NAMES_ATTR]
124+
[$this->perunFacilityReqAupsAttr, $this->perunFacilityVoShortNames]
133125
);
134126

135127
if (isset($this->perunFacilityReqAupsAttr, $facilityAttrValues) &&
136128
is_array($facilityAttrValues[$this->perunFacilityReqAupsAttr])) {
137-
foreach ($facilityAttrValues[$this->perunFacilityReqAupsAttr] as $facilityAup) {
129+
foreach (array_values($facilityAttrValues[$this->perunFacilityReqAupsAttr]) as $facilityAup) {
138130
array_push($requiredAups, $facilityAup);
139131
}
140132
}
141133

142134
if (isset($this->perunFacilityVoShortNames, $facilityAttrValues) &&
143135
is_array($facilityAttrValues[$this->perunFacilityVoShortNames])) {
144-
foreach ($facilityAttrValues[$this->perunFacilityVoShortNames] as $facilityVoShortName) {
136+
foreach (array_values($facilityAttrValues[$this->perunFacilityVoShortNames]) as $facilityVoShortName) {
145137
array_push($voShortNames, $facilityVoShortName);
146138
}
147139
}

0 commit comments

Comments
 (0)