Skip to content

Commit

Permalink
Remove unused use-statements and order them alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Jan 15, 2024
1 parent 123b38e commit da36162
Show file tree
Hide file tree
Showing 21 changed files with 26 additions and 76 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.phpunit.cache/
vendor/
composer.lock
lib/WebAuthn/restena.php
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true,
"simplesamlphp/composer-module-installer": true
"simplesamlphp/composer-module-installer": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
10 changes: 6 additions & 4 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache">
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage" lowUpperBound="35" highLowerBound="70"/>
Expand All @@ -17,4 +14,9 @@
</testsuite>
</testsuites>
<logging/>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
4 changes: 0 additions & 4 deletions src/Auth/Process/WebAuthn.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@

namespace SimpleSAML\Module\webauthn\Auth\Process;

use SimpleSAML\Assert\Assert;
use SimpleSAML\Auth;
use SimpleSAML\Configuration;
use SimpleSAML\Error;
use SimpleSAML\Logger;
use SimpleSAML\Module;
use SimpleSAML\Module\webauthn\Store;
use SimpleSAML\Module\webauthn\WebAuthn\StateData;
use SimpleSAML\Module\webauthn\WebAuthn\StaticProcessHelper;
use SimpleSAML\Utils;

class WebAuthn extends Auth\ProcessingFilter
{
Expand Down
5 changes: 1 addition & 4 deletions src/Auth/Source/Passwordless.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@

namespace SimpleSAML\Module\webauthn\Auth\Source;

use SimpleSAML\Assert\Assert;
use SimpleSAML\Auth\Source;
use SimpleSAML\Configuration;
use SimpleSAML\Error;
use SimpleSAML\Logger;
use SimpleSAML\Module\webauthn\Controller\WebAuthn;
use SimpleSAML\Module\webauthn\WebAuthn\StateData;
use SimpleSAML\Module\webauthn\WebAuthn\StaticProcessHelper;
use SimpleSAML\Module\webauthn\Controller\WebAuthn;

class Passwordless extends Source
{
Expand Down
7 changes: 0 additions & 7 deletions src/Auth/Source/Supercharged.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@

namespace SimpleSAML\Module\webauthn\Auth\Source;

use SimpleSAML\Assert\Assert;
use SimpleSAML\Auth\Source;
use SimpleSAML\Configuration;
use SimpleSAML\Error;
use SimpleSAML\Logger;
use SimpleSAML\Module\webauthn\WebAuthn\StateData;
use SimpleSAML\Module\webauthn\WebAuthn\StaticProcessHelper;
use SimpleSAML\Module\webauthn\Controller\WebAuthn;

class Supercharged extends Passwordless
{
Expand Down
5 changes: 1 addition & 4 deletions src/Controller/AuthProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace SimpleSAML\Module\webauthn\Controller;

use DateTime;
use Exception;
use SimpleSAML\Auth;
use SimpleSAML\Auth\Source;
Expand All @@ -16,10 +15,8 @@
use SimpleSAML\Module\webauthn\WebAuthn\WebAuthnAbstractEvent;
use SimpleSAML\Module\webauthn\WebAuthn\WebAuthnAuthenticationEvent;
use SimpleSAML\Session;
use SimpleSAML\Utils;
use SimpleSAML\XHTML\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
Expand Down
2 changes: 0 additions & 2 deletions src/Controller/ManageToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
use SimpleSAML\Error;
use SimpleSAML\HTTP\RunnableResponse;
use SimpleSAML\Logger;
use SimpleSAML\Module;
use SimpleSAML\Module\webauthn\WebAuthn\StaticProcessHelper;
use SimpleSAML\Session;
use SimpleSAML\Utils;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down
8 changes: 0 additions & 8 deletions src/Controller/PushbackUserPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@

namespace SimpleSAML\Module\webauthn\Controller;

use DateTime;
use Exception;
use SimpleSAML\Auth;
use SimpleSAML\Auth\Source;
use SimpleSAML\Configuration;
use SimpleSAML\Error;
use SimpleSAML\HTTP\RunnableResponse;
use SimpleSAML\Logger;
use SimpleSAML\Module;
use SimpleSAML\Module\webauthn\Auth\Source\AuthSourceOverloader;
use SimpleSAML\Module\webauthn\WebAuthn\WebAuthnAbstractEvent;
use SimpleSAML\Module\webauthn\WebAuthn\WebAuthnAuthenticationEvent;
use SimpleSAML\Session;
use SimpleSAML\Utils;
use SimpleSAML\XHTML\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/RegProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
use SimpleSAML\Module\webauthn\WebAuthn\WebAuthnRegistrationEvent;
use SimpleSAML\Session;
use SimpleSAML\Utils;
use SimpleSAML\XHTML\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Controller/Registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
use SimpleSAML\HTTP\RunnableResponse;
use SimpleSAML\Logger;
use SimpleSAML\Metadata\MetaDataStorageHandler;
use SimpleSAML\Module;
use SimpleSAML\Module\webauthn\Store;
use SimpleSAML\Module\webauthn\WebAuthn\StateData;
use SimpleSAML\Module\webauthn\WebAuthn\StaticProcessHelper;
use SimpleSAML\Module\webauthn\Store;
use SimpleSAML\Session;
use SimpleSAML\Utils;
use SimpleSAML\XHTML\Template;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down
3 changes: 0 additions & 3 deletions src/Controller/Supercharged.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@

namespace SimpleSAML\Module\webauthn\Controller;

use SimpleSAML\Auth;
use SimpleSAML\Configuration;
use SimpleSAML\Error;
use SimpleSAML\Logger;
use SimpleSAML\Module;
use SimpleSAML\Session;
use SimpleSAML\Utils;
use SimpleSAML\XHTML\Template;
use Symfony\Component\HttpFoundation\Request;
use SimpleSAML\Module\webauthn\Store;

/**
* Controller class for the webauthn module.
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/WebAuthn.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
use SimpleSAML\Error;
use SimpleSAML\Logger;
use SimpleSAML\Module;
use SimpleSAML\Module\webauthn\Store;
use SimpleSAML\Session;
use SimpleSAML\Utils;
use SimpleSAML\XHTML\Template;
use Symfony\Component\HttpFoundation\Request;
use SimpleSAML\Module\webauthn\Store;

/**
* Controller class for the webauthn module.
Expand Down
2 changes: 1 addition & 1 deletion src/WebAuthn/WebAuthnAbstractEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use CBOR\Decoder;
use CBOR\OtherObject;
use CBOR\Tag;
use CBOR\StringStream;
use CBOR\Tag;
use SimpleSAML\Utils\HTTP as HTTPHelper;

/**
Expand Down
14 changes: 8 additions & 6 deletions src/WebAuthn/WebAuthnRegistrationEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
namespace SimpleSAML\Module\webauthn\WebAuthn;

use Cose\Key\Ec2Key;
use Cose\Key\RsaKey;
use Exception;
use SimpleSAML\Error\Error;
use SimpleSAML\Error\InvalidCredential;
use SimpleSAML\Logger;
use SimpleSAML\Module\webauthn\WebAuthn\AAGUID;
use SimpleSAML\Utils;
use SimpleSAML\Utils\Config as SSPConfig;
use SpomkyLabs\Pki\ASN1\Type\UnspecifiedType;

/**
Expand Down Expand Up @@ -380,8 +377,13 @@ private function commonX5cSignatureChecks(array $attestationArray): void
* §8.2 Step 2 Bullet 1: check signature
*/
$retCode = openssl_verify($sigdata, $stmtDecoded['sig'], $keyResource, "sha256");
if ( $retCode !== 1) {
$this->fail("Packed signature mismatch (return code $retCode, for :authdata:".$attestationArray['authData']." - :clientDataHash:".$this->clientDataHash." - :signature:".$stmtDecoded['sig']."), attestation failed.");
if ($retCode !== 1) {
$this->fail(sprintf(
"Packed signature mismatch (return code $retCode, for :authdata:%s - :clientDataHash:%s - :signature:%s), attestation failed.",
$attestationArray['authData'],
$this->clientDataHash,
$stmtDecoded['sig'],
));
}
$this->pass("x5c sig check passed.");
}
Expand All @@ -397,7 +399,7 @@ private function validateAttestationFormatPacked(array $attestationArray): void
* §7.1 Step 16: attestation is either done with x5c or ecdaa.
*/
if (isset($stmtDecoded['x5c'])) {
$this->commonX5cSignatureChecks($attestationArray);
$this->commonX5cSignatureChecks($attestationArray);
$this->validateAttestationFormatPackedX5C($attestationArray);
} elseif (isset($stmtDecoded['ecdaa'])) {
$this->fail("ecdaa attestation not supported right now.");
Expand Down
7 changes: 2 additions & 5 deletions tests/src/Controller/AuthProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@
use PHPUnit\Framework\TestCase;
use SimpleSAML\Auth\State;
use SimpleSAML\Configuration;
use SimpleSAML\Error;
use SimpleSAML\HTTP\RunnableResponse;
use SimpleSAML\Logger;
use SimpleSAML\Module\webauthn\Controller;
use SimpleSAML\Session;
use SimpleSAML\Utils;
use SimpleSAML\XHTML\Template;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down Expand Up @@ -94,7 +90,8 @@ public static function loadState(string $id, string $stage, bool $allowMissing =

$this->expectException(Exception::class);
$this->expectExceptionMessage(
"User attempted to authenticate with an unknown credential ID. This should already have been prevented by the browser!"
"User attempted to authenticate with an unknown credential ID. This"
. " should already have been prevented by the browser!"
);
$c->main($request);
}
Expand Down
4 changes: 0 additions & 4 deletions tests/src/Controller/ManageTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@
use PHPUnit\Framework\TestCase;
use SimpleSAML\Auth\State;
use SimpleSAML\Configuration;
use SimpleSAML\Error;
use SimpleSAML\HTTP\RunnableResponse;
use SimpleSAML\Logger;
use SimpleSAML\Module\webauthn\Controller;
use SimpleSAML\Session;
use SimpleSAML\Utils;
use SimpleSAML\XHTML\Template;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down
4 changes: 0 additions & 4 deletions tests/src/Controller/RegProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
use PHPUnit\Framework\TestCase;
use SimpleSAML\Auth\State;
use SimpleSAML\Configuration;
use SimpleSAML\Error;
use SimpleSAML\HTTP\RunnableResponse;
use SimpleSAML\Logger;
use SimpleSAML\Module\webauthn\Controller;
use SimpleSAML\Session;
use SimpleSAML\Utils;
use SimpleSAML\XHTML\Template;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down
4 changes: 0 additions & 4 deletions tests/src/Controller/RegistrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
use PHPUnit\Framework\TestCase;
use SimpleSAML\Auth;
use SimpleSAML\Configuration;
use SimpleSAML\Error;
use SimpleSAML\HTTP\RunnableResponse;
use SimpleSAML\Logger;
use SimpleSAML\Module\webauthn\Controller;
use SimpleSAML\Session;
use SimpleSAML\Utils;
use SimpleSAML\XHTML\Template;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down
6 changes: 1 addition & 5 deletions tests/src/Controller/StateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@
namespace SimpleSAML\Test\Module\webauthn\Controller;

use PHPUnit\Framework\TestCase;
use SimpleSAML\Auth\State;
use SimpleSAML\Configuration;
use SimpleSAML\Error;
use SimpleSAML\HTTP\RunnableResponse;
use SimpleSAML\Logger;
use SimpleSAML\Module\webauthn\Controller;
use SimpleSAML\Session;
use SimpleSAML\Utils;
use SimpleSAML\XHTML\Template;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down Expand Up @@ -127,7 +123,7 @@ public function testNoState(
/**
* @return array
*/
public function stateTestsProvider(): array
public static function stateTestsProvider(): array
{
return [
['POST', 'authprocess', Controller\AuthProcess::class, 'main'],
Expand Down
4 changes: 0 additions & 4 deletions tests/src/Controller/WebAuthnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
use PHPUnit\Framework\TestCase;
use SimpleSAML\Auth\State;
use SimpleSAML\Configuration;
use SimpleSAML\Error;
use SimpleSAML\HTTP\RunnableResponse;
use SimpleSAML\Logger;
use SimpleSAML\Module\webauthn\Controller;
use SimpleSAML\Session;
use SimpleSAML\Utils;
use SimpleSAML\XHTML\Template;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down

0 comments on commit da36162

Please sign in to comment.