Skip to content

Commit c2bb30f

Browse files
tvdijenthijskh
authored andcommitted
Fix Psalm & phpcs issues
1 parent ce16e21 commit c2bb30f

2 files changed

Lines changed: 25 additions & 16 deletions

File tree

src/Auth/Process/SFO.php

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
*/
2828
class SFO extends Auth\ProcessingFilter
2929
{
30-
/** @var array */
31-
private array $metadata;
30+
/** @var \SimpleSAML\Configuration */
31+
private Configuration $metadata;
3232

33-
/** @var array */
34-
private array $idpMetadata;
33+
/** @var \SimpleSAML\Configuration */
34+
private Configuration $idpMetadata;
3535

3636
/** @var string */
3737
private string $subjectidattribute;
@@ -51,7 +51,7 @@ public function __construct(array $config, $reserved)
5151
parent::__construct($config, $reserved);
5252

5353
$this->subjectidattribute = $config['subjectattribute'];
54-
if (isset($config['skipentities']) ) {
54+
if (isset($config['skipentities'])) {
5555
$this->skipentities = $config['skipentities'];
5656
}
5757

@@ -69,7 +69,7 @@ public function __construct(array $config, $reserved)
6969
*/
7070
public function process(array &$state): void
7171
{
72-
foreach($this->skipentities as $skip) {
72+
foreach ($this->skipentities as $skip) {
7373
if ($skip === $state['SPMetadata']['entityid'] || in_array($skip, $state['saml:RequesterID'], true)) {
7474
Logger::info('SFO - skipping SFO for entity ' . var_export($skip, true));
7575
return;
@@ -80,13 +80,16 @@ public function process(array &$state): void
8080
$state['sfo:idp:entityid'] = $this->idpMetadata->getString('entityid');
8181
$samlstateid = Auth\State::saveState($state, 'stepupsfo:pre');
8282

83-
if (empty($state['Attributes'][$this->subjectidattribute]) ) {
83+
if (empty($state['Attributes'][$this->subjectidattribute])) {
8484
throw new Exception("Subjectid " . $this->subjectidattribute . " not found in attributes.");
8585
}
8686

8787
$subjectid = $state['Attributes'][$this->subjectidattribute][0];
88-
if (substr($subjectid,0,18) !== 'urn:collab:person:' ) {
89-
throw new Exception("Subjectid " . var_export($subjectid,true) . " does not start with urn:collab:person:");
88+
if (substr($subjectid, 0, 18) !== 'urn:collab:person:') {
89+
throw new Exception(sprintf(
90+
"Subjectid %s does not start with urn:collab:person:",
91+
var_export($subjectid, true)
92+
));
9093
}
9194

9295
$nameid = new NameID();
@@ -138,12 +141,17 @@ private function startSFO(Configuration $idpMetadata, NameID $nameid, $relay): v
138141
$ar->setNameId($nameid);
139142
$ar->setRelayState($relay);
140143

141-
Logger::debug('Sending SAML 2 SFO AuthnRequest for ' . $nameid->getValue() . ' to ' .
142-
var_export($idpMetadata->getString('entityid'), true). ' with id ' . $ar->getId());
144+
Logger::debug(sprintf(
145+
'Sending SAML 2 SFO AuthnRequest for %s to %s with id %s',
146+
$nameid->getValue(),
147+
var_export($idpMetadata->getString('entityid'), true),
148+
$ar->getId()
149+
));
143150

144-
$dst = $idpMetadata->getEndpointPrioritizedByBinding('SingleSignOnService',
145-
[C::BINDING_HTTP_REDIRECT]
146-
);
151+
$dst = $idpMetadata->getEndpointPrioritizedByBinding(
152+
'SingleSignOnService',
153+
[C::BINDING_HTTP_REDIRECT]
154+
);
147155

148156
$ar->setDestination($dst['Location']);
149157

src/Controller/SFO.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace SimpleSAML\Module\stepupsfo\Controller;
66

7+
use Exception;
78
use SAML2\Binding;
89
use SAML2\HTTPPost;
910
use SAML2\Response;
@@ -98,7 +99,7 @@ public function acs(): Template
9899
/* Not found. */
99100
throw new Error\Exception(sprintf(
100101
'Could not find the metadata of SFO IdP with entity ID %s',
101-
var_export($entityId, true)
102+
var_export($idpEntityId, true)
102103
));
103104
}
104105

@@ -113,7 +114,7 @@ public function acs(): Template
113114
$t->data['status'] = $e->getStatus();
114115
$t->data['subStatus'] = $e->getSubStatus();
115116
$t->data['statusMessage'] = $e->getStatusMessage();
116-
$t->data['selfserviceUrl'] = $idpMetadata->getString('sfo:selfserviceUrl', '');
117+
$t->data['selfserviceUrl'] = $idpMetadata->getOptionalString('sfo:selfserviceUrl', '');
117118

118119
return $t;
119120
}

0 commit comments

Comments
 (0)