Skip to content

Commit

Permalink
Review changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioigoume committed Nov 15, 2024
1 parent 6a52c3b commit a911fa7
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 60 deletions.
11 changes: 10 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"simplesamlphp/composer-module-installer": "^1.3",
"simplesamlphp/simplesamlphp": "^2.2",
"simplesamlphp/xml-cas": "^v1.3",
"simplesamlphp/xml-common": "^v1.18",
"simplesamlphp/xml-common": "^v1.17",
"simplesamlphp/xml-soap": "^v1.5"
},
"require-dev": {
Expand All @@ -54,5 +54,14 @@
},
"suggest": {
"ext-pdo": "*"
},
"scripts": {
"validate": [
"vendor/bin/phpunit --no-coverage --testdox",
"vendor/bin/phpcs -p"
],
"tests": [
"vendor/bin/phpunit --no-coverage"
]
}
}
26 changes: 6 additions & 20 deletions public/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,25 +183,16 @@
// Get the state.
// If we come from an authproc filter, we will load the state from the stateId.
// If not, we will get the state from the AuthSource Data
try {
$state = $authProcId !== null ?
$attributeExtractor->manageState($authProcId) :
$as->getAuthDataArray();
} catch (\SimpleSAML\Error\NoState $e) {
var_export($e, true);
die();
}
$state = $authProcId !== null ?
$attributeExtractor->manageState($authProcId) :

Check failure on line 187 in public/login.php

View workflow job for this annotation

GitHub Actions / Quality control

PossiblyInvalidArgument

public/login.php:187:38: PossiblyInvalidArgument: Argument 1 of SimpleSAML\Module\casserver\Cas\AttributeExtractor::manageState expects string, but possibly different type non-empty-array<int|non-empty-string, array<int|non-empty-string, mixed>|string>|string provided (see https://psalm.dev/092)
$as->getAuthDataArray();

// Attribute Handler
$state['ReturnTo'] = $returnUrl;
if ($authProcId !== null) {
$state[ProcessingChain::AUTHPARAM] = $authProcId;
}
try {
$mappedAttributes = $attributeExtractor->extractUserAndAttributes($state);
} catch (\SimpleSAML\Error\Exception $e) {
var_export($e, true);
die();
}
$mappedAttributes = $attributeExtractor->extractUserAndAttributes($state);

$serviceTicket = $ticketFactory->createServiceTicket([
'service' => $serviceUrl,
Expand Down Expand Up @@ -245,10 +236,5 @@
$httpUtils->redirectTrustedURL($httpUtils->addURLParameters($serviceUrl, $parameters));

Check failure on line 236 in public/login.php

View workflow job for this annotation

GitHub Actions / Quality control

PossiblyInvalidArgument

public/login.php:236:65: PossiblyInvalidArgument: Argument 1 of SimpleSAML\Utils\HTTP::addURLParameters expects string, but possibly different type non-empty-array<int|non-empty-string, array<int|non-empty-string, mixed>|string>|null|string provided (see https://psalm.dev/092)
} else {
// POST
try {
$httpUtils->submitPOSTData($serviceUrl, $parameters);
} catch (\SimpleSAML\Error\Exception $e) {
var_export($e, true);
die();
}
$httpUtils->submitPOSTData($serviceUrl, $parameters);

Check failure on line 239 in public/login.php

View workflow job for this annotation

GitHub Actions / Quality control

PossiblyInvalidArgument

public/login.php:239:32: PossiblyInvalidArgument: Argument 1 of SimpleSAML\Utils\HTTP::submitPOSTData expects string, but possibly different type non-empty-array<int|non-empty-string, array<int|non-empty-string, mixed>|string>|null|string provided (see https://psalm.dev/092)
}
2 changes: 1 addition & 1 deletion src/Cas/AttributeExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AttributeExtractor

public function __construct(
Configuration $casconfig,
ProcessingChainFactory $processingChainFactory
ProcessingChainFactory $processingChainFactory,
) {
$this->casconfig = $casconfig;
$this->processingChainFactory = $processingChainFactory;
Expand Down
13 changes: 2 additions & 11 deletions src/Cas/Factories/ProcessingChainFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,9 @@ public function __construct(
*/
public function build(array $state): ProcessingChain
{
$idpMetadata = [
'entityid' => $state['Source']['entityid'] ?? '',
// ProcessChain needs to know the list of authproc filters we defined in casserver configuration
'authproc' => $this->casconfig->getOptionalArray('authproc', []),
];
$spMetadata = [
'entityid' => $state['Destination']['entityid'] ?? '',
];

return new ProcessingChain(
$idpMetadata,
$spMetadata,
$state['Source'],
$state['Destination'],
'casserver',
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Cas/Protocol/SamlValidateResponder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use SimpleSAML\Configuration;
use SimpleSAML\Module\casserver\Shib13\AuthnResponse;
use SimpleSAML\SOAP\XML\env_200305\Body;
use SimpleSAML\SOAP\XML\env_200305\Envelope;
use SimpleSAML\SOAP\XML\env_200106\Body;
use SimpleSAML\SOAP\XML\env_200106\Envelope;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\SerializableElementInterface;
Expand Down Expand Up @@ -64,11 +64,11 @@ public function convertToSaml(array $ticket): Chunk

/**
* @param \SimpleSAML\XML\SerializableElementInterface $samlResponse
* @return \SimpleSAML\SOAP\XML\env\Envelope
* @return \SimpleSAML\SOAP\XML\env_200106\Envelope
*/
public function wrapInSoap(SerializableElementInterface $samlResponse): Envelope
{
$body = new Body(null, [$samlResponse]);
$body = new Body([$samlResponse]);
return new Envelope($body);
}
}
12 changes: 0 additions & 12 deletions tests/config/jwks-cert.pem

This file was deleted.

10 changes: 0 additions & 10 deletions tests/config/jwks-key.pem

This file was deleted.

2 changes: 1 addition & 1 deletion tests/src/Cas/Protocol/SamlValidateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use PHPUnit\Framework\TestCase;
use SimpleSAML\Module\casserver\Cas\Protocol\SamlValidateResponder;
use SimpleSAML\SOAP\XML\env_200305\Envelope;
use SimpleSAML\SOAP\XML\env_200106\Envelope;

class SamlValidateTest extends TestCase
{
Expand Down

0 comments on commit a911fa7

Please sign in to comment.