Skip to content

Commit 01d93fc

Browse files
committed
Fix CI
1 parent b7cc8ff commit 01d93fc

4 files changed

Lines changed: 16 additions & 20 deletions

File tree

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ jobs:
117117
with:
118118
php-version: ${{ matrix.php-versions }}
119119
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix,\
120-
session, sodium, spl, xml
120+
session, sodium, spl, xml, zip
121121
tools: composer
122122
ini-values: error_reporting=E_ALL
123123
coverage: none

src/Auth/Process/OTP2YubiPrefix.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class OTP2YubiPrefix extends Auth\ProcessingFilter
6363
* Filter out YubiKey 'otp' attribute and replace it with
6464
* a 'yubiPrefix' attribute that leaves out the dynamic part.
6565
*
66-
* @param array &$state The state we should update.
66+
* @param array<mixed> &$state The state we should update.
6767
*/
6868
public function process(array &$state): void
6969
{

src/Auth/Source/YubiKey.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,19 @@ class YubiKey extends Auth\Source
3939
/**
4040
* The string used to identify our states.
4141
*/
42-
public const STAGEID = '\SimpleSAML\Module\authYubiKey\Auth\Source\YubiKey.state';
42+
public const string STAGEID = '\SimpleSAML\Module\authYubiKey\Auth\Source\YubiKey.state';
4343

4444
/**
4545
* The number of characters of the OTP that is the secure token.
4646
* The rest is the user id.
4747
*/
48-
public const TOKENSIZE = 32;
48+
public const int TOKENSIZE = 32;
4949

5050
/**
5151
* The key of the AuthId field in the state.
5252
*/
53-
public const AUTHID = '\SimpleSAML\Module\authYubiKey\Auth\Source\YubiKey.AuthId';
53+
public const string AUTHID = '\SimpleSAML\Module\authYubiKey\Auth\Source\YubiKey.AuthId';
54+
5455

5556
/**
5657
* The client id/key for use with the Auth_Yubico PHP module.
@@ -65,8 +66,8 @@ class YubiKey extends Auth\Source
6566
/**
6667
* Constructor for this authentication source.
6768
*
68-
* @param array $info Information about this authentication source.
69-
* @param array $config Configuration.
69+
* @param array<mixed> $info Information about this authentication source.
70+
* @param array<mixed> $config Configuration.
7071
*/
7172
public function __construct(array $info, array $config)
7273
{
@@ -87,7 +88,7 @@ public function __construct(array $info, array $config)
8788
* This function saves the information about the login, and redirects to a
8889
* login page.
8990
*
90-
* @param array &$state Information about the current authentication.
91+
* @param array<mixed> &$state Information about the current authentication.
9192
*/
9293
public function authenticate(array &$state): void
9394
{
@@ -120,9 +121,6 @@ public static function handleLogin(
120121
) {
121122
/* Retrieve the authentication state. */
122123
$state = Auth\State::loadState($authStateId, self::STAGEID);
123-
if (is_null($state)) {
124-
throw new Error\NoState();
125-
}
126124

127125
/* Find authentication source. */
128126
Assert::keyExists($state, self::AUTHID);
@@ -158,8 +156,6 @@ public static function handleLogin(
158156

159157
$state['Attributes'] = $attributes;
160158
Auth\Source::completeAuth($state);
161-
162-
assert(false);
163159
}
164160

165161

@@ -185,8 +181,7 @@ public static function getYubiKeyPrefix(#[\SensitiveParameter] string $otp): str
185181
*
186182
* Note that both the username and the password are UTF-8 encoded.
187183
*
188-
* @param string $otp
189-
* @return array Associative array with the users attributes.
184+
* @return array<mixed> Associative array with the users attributes.
190185
*/
191186
protected function login(#[\SensitiveParameter] string $userInputOtp): array
192187
{

tests/src/Controller/YubikeyTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use SimpleSAML\Module\authYubiKey\Auth\Source\YubiKey;
1212
use SimpleSAML\Module\authYubiKey\Controller;
1313
use SimpleSAML\Session;
14-
use SimpleSAML\XHTML\Template;
1514
use Symfony\Component\HttpFoundation\Request;
1615

1716
/**
@@ -63,7 +62,9 @@ public function testOtpNoState(): void
6362
$c = new Controller\Yubikey($this->config, $this->session);
6463

6564
$this->expectException(Error\BadRequest::class);
66-
$this->expectExceptionMessage("BADREQUEST('%REASON%' => 'Missing AuthState parameter.')");
65+
$this->expectExceptionMessage(
66+
'{"errorCode":"BADREQUEST","%REASON%":"Missing AuthState parameter."}',
67+
);
6768

6869
$c->main($request);
6970
}
@@ -86,7 +87,6 @@ public function testOtpNoOtp(): void
8687
$response = $c->main($request);
8788

8889
$this->assertTrue($response->isSuccessful());
89-
$this->assertInstanceOf(Template::class, $response);
9090
}
9191

9292

@@ -106,18 +106,19 @@ public function testWrongOtp(): void
106106
$c = new Controller\Yubikey($this->config, $this->session);
107107
$c->setYubikey(new class (['AuthId' => 'authYubiKey'], []) extends YubiKey
108108
{
109+
/** @phpstan-ignore constructor.unusedParameter, constructor.unusedParameter */
109110
public function __construct(array $info, array $config)
110111
{
111112
}
112113

113-
public static function handleLogin(string $authStateId, string $otp): ?string
114+
115+
public static function handleLogin(string $authStateId, string $otp): string
114116
{
115117
return 'WRONGUSERPASS';
116118
}
117119
});
118120
$response = $c->main($request);
119121

120122
$this->assertTrue($response->isSuccessful());
121-
$this->assertInstanceOf(Template::class, $response);
122123
}
123124
}

0 commit comments

Comments
 (0)