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

Commit 93dae97

Browse files
Dominik František Bučíkvyskocilpavel
authored andcommitted
FIX: Fixed filtering of ACRs in Disco.php (#160)
- wrong conditions in loop caused the filtering not to work at all (cherry picked from commit 5fcb7c7)
1 parent 9bd9085 commit 93dae97

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
3-
3+
44
## [Unreleased]
5+
#### Fixed
6+
- Fixed removal of filtered authnContextClassRefs in disco
57

68
## [v5.1.0]
79
#### Added
@@ -371,6 +373,7 @@ when storing one Perun attribute to more SAML attribute
371373
## [v1.0.0]
372374

373375
[Unreleased]: https://github.com/CESNET/perun-simplesamlphp-module/tree/master
376+
[v5.1.0]: https://github.com/CESNET/perun-simplesamlphp-module/tree/v5.1.0
374377
[v5.0.0]: https://github.com/CESNET/perun-simplesamlphp-module/tree/v5.0.0
375378
[v4.1.1]: https://github.com/CESNET/perun-simplesamlphp-module/tree/v4.1.1
376379
[v4.1.0]: https://github.com/CESNET/perun-simplesamlphp-module/tree/v4.1.0

lib/Disco.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public function __construct(
123123
if (isset($state['IdPMetadata']['entityid'])) {
124124
$this->proxyIdpEntityId = $state['IdPMetadata']['entityid'];
125125
}
126+
State::saveState($state, self::SAML_SP_SSO);
126127
}
127128
$e = explode("=", $returnURL)[0];
128129
$newReturnURL = $e . "=" . urlencode($id);
@@ -457,11 +458,17 @@ public function removeAuthContextClassRefWithPrefixes(&$state)
457458
unset($state[self::SAML_REQUESTED_AUTHN_CONTEXT][self::STATE_AUTHN_CONTEXT_CLASS_REF]);
458459
$filteredAcrs = [];
459460
foreach ($this->originalAuthnContextClassRef as $acr) {
461+
$acr = trim($acr);
462+
$retain = true;
460463
foreach ($prefixes as $prefix) {
461-
if (!(substr($acr, 0, strlen($prefix)) === $prefix)) {
462-
array_push($filteredAcrs, $acr);
464+
if (substr($acr, 0, strlen($prefix)) === $prefix) {
465+
$retain = false;
466+
break;
463467
}
464468
}
469+
if ($retain) {
470+
array_push($filteredAcrs, $acr);
471+
}
465472
}
466473
if (!empty($filteredAcrs)) {
467474
$state[self::SAML_REQUESTED_AUTHN_CONTEXT][self::STATE_AUTHN_CONTEXT_CLASS_REF] = $filteredAcrs;

0 commit comments

Comments
 (0)