Skip to content

Commit 74ca9e6

Browse files
committed
Add composer.json and use Webmozart assertions
1 parent 1960fb6 commit 74ca9e6

File tree

6 files changed

+55
-6
lines changed

6 files changed

+55
-6
lines changed

composer.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "simplesamlphp/simplesamlphp-module-adfs",
3+
"description": "A module that implements the WS-federation IDP",
4+
"type": "simplesamlphp-module",
5+
"keywords": ["simplesamlphp", "adfs"],
6+
"license": "LGPL-3.0-or-later",
7+
"authors": [
8+
{
9+
"name": "Tim van Dijen",
10+
"email": "tvdijen@gmail.com"
11+
}
12+
],
13+
"config": {
14+
"preferred-install": {
15+
"simplesamlphp/simplesamlphp": "source",
16+
"*": "dist"
17+
}
18+
},
19+
"autoload": {
20+
"psr-4": {
21+
"SimpleSAML\\modules\\adfs\\": "lib/"
22+
}
23+
},
24+
"autoload-dev": {
25+
"psr-4": {
26+
"Tests\\SimpleSAML\\modules\\riak\\TestFiles\\": "tests/files",
27+
"SimpleSAML\\Test\\Utils\\": "vendor/simplesamlphp/simplesamlphp/tests/Utils"
28+
}
29+
},
30+
"require": {
31+
"php": ">=5.5",
32+
"simplesamlphp/composer-module-installer": "~1.1",
33+
"webmozart/assert": "~1.4",
34+
},
35+
"require-dev": {
36+
"simplesamlphp/simplesamlphp": "^1.17",
37+
"phpunit/phpunit": "~4.8.36"
38+
},
39+
"support": {
40+
"issues": "https://github.com/tvdijen/simplesamlphp-module-adfs/issues",
41+
"source": "https://github.com/tvdijen/simplesamlphp-module-adfs"
42+
}
43+
}

lib/IdP/ADFS.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public static function receiveLogoutMessage(\SimpleSAML\IdP $idp)
338338
// this implies an override to normal sp notification
339339
if (isset($_GET['wreply']) && !empty($_GET['wreply'])) {
340340
$idp->doLogoutRedirect(\SimpleSAML\Utils\HTTP::checkURLAllowed($_GET['wreply']));
341-
assert(false);
341+
throw new \Exception("Code should never be reached");
342342
}
343343

344344
$state = [

lib/SAML2/XML/fed/Endpoint.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace SimpleSAML\Module\adfs\SAML2\XML\fed;
44

5+
use Webmozard\Assert\Assert;
6+
57
/**
68
* Class representing fed Endpoint.
79
*
@@ -18,8 +20,8 @@ class Endpoint
1820
*/
1921
public static function appendXML(\DOMElement $parent, $name, $address)
2022
{
21-
assert(is_string($name));
22-
assert(is_string($address));
23+
Assert::string($name);
24+
Assert::string($address);
2325

2426
$e = $parent->ownerDocument->createElement($name);
2527
$parent->appendChild($e);

lib/SAML2/XML/fed/SecurityTokenServiceType.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace SimpleSAML\Module\adfs\SAML2\XML\fed;
44

5+
use Webmozart\Assert\Assert;
6+
57
/**
68
* Class representing SecurityTokenServiceType RoleDescriptor.
79
*
@@ -45,7 +47,7 @@ public function __construct(\DOMElement $xml = null)
4547
*/
4648
public function toXML(\DOMElement $parent)
4749
{
48-
assert(is_string($this->Location));
50+
Assert::string($this->Location);
4951

5052
$e = parent::toXML($parent);
5153
$e->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:fed', Constants::NS_FED);

www/idp/metadata.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use Webmozart\Assert\Assert;
4+
35
// load configuration and metadata
46
$config = \SimpleSAML\Configuration::getInstance();
57
$metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler();
@@ -46,7 +48,7 @@
4648

4749
if ($idpmeta->hasValue('https.certificate')) {
4850
$httpsCert = \SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, true, 'https.');
49-
assert(isset($httpsCert['certData']));
51+
Assert::keyExists($httpsCert, 'certData');
5052
$availableCerts['https.crt'] = $httpsCert;
5153
$keys[] = [
5254
'type' => 'X509Certificate',

www/idp/prp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
} elseif ($_GET['wa'] === 'wsignin1.0') {
2020
\SimpleSAML\Module\adfs\IdP\ADFS::receiveAuthnRequest($idp);
2121
}
22-
assert(false);
22+
throw new \Exception("Code should never be reached");
2323
} elseif (isset($_GET['assocId'])) {
2424
// logout response from ADFS SP
2525
$assocId = $_GET['assocId']; // Association ID of the SP that sent the logout response

0 commit comments

Comments
 (0)