Skip to content

Commit

Permalink
Merge pull request NIIF#3 from shingo78/feature/simplesamlphp-2.1
Browse files Browse the repository at this point in the history
Upgrade SimpleSAMLphp to 2.1
  • Loading branch information
shingo78 authored Mar 21, 2024
2 parents fbed3ae + cc9a193 commit 16e296c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"description": "Attribute Aggregator implementation or SAML AttributeQuery",
"type": "simplesamlphp-module",
"require": {
"simplesamlphp/composer-module-installer": "~1.1",
"simplesamlphp/composer-module-installer": "^1.3",
"simplesamlphp/saml2": ">=4.0, <4.2.8 || >=4.5.1, ^4.6",
"ext-soap": "*"
},
"require-dev": {
"simplesamlphp/simplesamlphp": ">=1.14",
"simplesamlphp/simplesamlphp": ">=2.1",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5"
},
"autoload-dev": {
Expand Down
Empty file removed default-enable
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* @version $Id$
*/

declare(strict_types=1);

namespace SimpleSAML\Module\attributeaggregator\Auth\Process;

class attributeaggregator extends \SimpleSAML\Auth\ProcessingFilter
Expand Down Expand Up @@ -36,7 +38,7 @@ class attributeaggregator extends \SimpleSAML\Auth\ProcessingFilter
private $required = FALSE;

/**
*
*
* nameIdFormat, the format of the attributeId. Default is "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent";
* @var unknown_type
*/
Expand Down Expand Up @@ -87,7 +89,7 @@ class attributeaggregator extends \SimpleSAML\Auth\ProcessingFilter
* @param array $config Configuration information
* @param mixed $reserved For future use
*/
public function __construct($config, $reserved)
public function __construct(array &$config, $reserved)
{
assert('is_array($config)');
parent::__construct($config, $reserved);
Expand All @@ -102,7 +104,7 @@ public function __construct($config, $reserved)
if (!empty($config["attributeId"])){
$this->attributeId = $config["attributeId"];
}

if (!empty($config["required"])){
$this->required = $config["required"];
}
Expand All @@ -122,7 +124,7 @@ public function __construct($config, $reserved)
if (array_key_exists("values", $attribute)) {
if (! is_array($attribute["values"])) {
throw new \SimpleSAML\Error\Exception("attributeaggregator: Invalid format of attributes array in the configuration");
}
}
}
if (array_key_exists('multiSource', $attribute)){
if(! preg_match('/^(merge|keep|override)$/', $attribute['multiSource']))
Expand All @@ -147,7 +149,7 @@ public function __construct($config, $reserved)
$metadata->getMetaData($this->entityId, 'attributeauthority-remote')
);
if ($this->aaMetadata->hasValue('AttributeService')) {
foreach ($this->aaMetadata->getArray('AttributeService',array()) as $aa_endpoint) {
foreach ($this->aaMetadata->getOptionalArray('AttributeService',array()) as $aa_endpoint) {
if ($aa_endpoint['Binding'] == \SAML2\Constants::BINDING_SOAP) {
$this->aaEndpoint = $aa_endpoint['Location'];
break;
Expand Down Expand Up @@ -177,7 +179,7 @@ public function __construct($config, $reserved)
*
* @param array &$state The state of the response.
*/
public function process(&$state)
public function process(array &$state): void
{
assert('is_array($state)');

Expand Down Expand Up @@ -222,7 +224,8 @@ public function process(&$state)
$query->setNameId($nameid);
$query->setAttributeNameFormat($this->attributeNameFormat);
$query->setAttributes($this->getRequestedAttributes()); // may be empty, then it's a noop
$query->setID(\SimpleSAML\Utils\Random::generateID());
$randomUtils = new \SimpleSAML\Utils\Random();
$query->setID($randomUtils->generateID());
// TODO: should this call be made optional?
\SimpleSAML\Module\saml\Message::addSign($this->selfMetadata,$this->aaMetadata,$query);

Expand All @@ -245,7 +248,7 @@ public function process(&$state)
$attributes_from_aa = array();
}
$this->mergeAttributes($state, $attributes_from_aa);

} catch (Exception $e) {
\SimpleSAML\Logger::info("Attribute query failed: ".$e->getMessage());
if ($this->required) {
Expand Down

0 comments on commit 16e296c

Please sign in to comment.