Skip to content

Commit 007c37a

Browse files
authored
feat: Support Laravel 10.0, and remove TokenBindingHandler (#419)
1 parent d8fb6ed commit 007c37a

File tree

7 files changed

+39
-31
lines changed

7 files changed

+39
-31
lines changed

.github/workflows/static.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
runs-on: ubuntu-latest
4545
strategy:
4646
matrix:
47-
php-version: ['8.1']
47+
php-version: ['8.2']
4848

4949
steps:
5050
- name: Checkout sources

.github/workflows/tests.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ jobs:
2828
strategy:
2929
fail-fast: false
3030
matrix:
31-
php-version: ['8.1']
32-
laravel-version: [9.*]
31+
php-version: ['8.1','8.2']
32+
laravel-version: [9.*,10.*]
3333
psr7: ['guzzle']
3434
include:
3535
- php-version: '8.1'
@@ -38,6 +38,12 @@ jobs:
3838
- php-version: '8.1'
3939
laravel-version: '9.*'
4040
psr7: 'discovery'
41+
- php-version: '8.2'
42+
laravel-version: '10.*'
43+
psr7: 'nyholm'
44+
- php-version: '8.2'
45+
laravel-version: '10.*'
46+
psr7: 'discovery'
4147

4248
steps:
4349
- name: Checkout sources
@@ -47,7 +53,7 @@ jobs:
4753
uses: shivammathur/setup-php@v2
4854
with:
4955
php-version: ${{ matrix.php-version }}
50-
coverage: none
56+
coverage: pcov
5157
extensions: sqlite3, gmp
5258
- name: Check PHP Version
5359
run: php -v
@@ -97,7 +103,7 @@ jobs:
97103
composer update --no-interaction --no-progress --prefer-dist
98104
99105
- name: Run test suite
100-
run: phpdbg -dmemory_limit=4G -qrr vendor/bin/phpunit -c phpunit.xml --log-junit ./results/results_${{ matrix.psr7 }}.xml --coverage-clover ./results/coverage_${{ matrix.psr7 }}.xml
106+
run: vendor/bin/phpunit -c phpunit.xml --log-junit ./results/results_${{ matrix.psr7 }}.xml --coverage-clover ./results/coverage_${{ matrix.psr7 }}.xml
101107

102108
- name: Fix results files
103109
run: sed -i -e "s%$GITHUB_WORKSPACE/%%g" *.xml
@@ -119,7 +125,7 @@ jobs:
119125
runs-on: ubuntu-latest
120126
strategy:
121127
matrix:
122-
php-version: ['8.1']
128+
php-version: ['8.2']
123129

124130
steps:
125131
- name: Checkout repository

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/vendor/
22
/results/
33
.phpunit.result.cache
4+
.phpunit.cache
45
composer.lock

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
],
2222
"require": {
2323
"php": ">=8.1",
24-
"illuminate/support": "^9.0",
24+
"illuminate/support": "^9.0 || ^10.0",
2525
"psr/http-factory-implementation": "1.0",
2626
"thecodingmachine/safe": "^2.0",
2727
"web-auth/cose-lib": "^4.0",
@@ -34,11 +34,11 @@
3434
"laravel/legacy-factories": "^1.0",
3535
"nunomaduro/larastan": "^2.0",
3636
"ocramius/package-versions": "^2.0",
37-
"orchestra/testbench": "^7.0",
37+
"orchestra/testbench": "^7.0 || ^8.0",
3838
"phpstan/phpstan-deprecation-rules": "^1.0",
3939
"phpstan/phpstan-phpunit": "^1.0",
4040
"phpstan/phpstan-strict-rules": "^1.0",
41-
"phpunit/phpunit": "^9.0",
41+
"phpunit/phpunit": "^9.5",
4242
"thecodingmachine/phpstan-safe-rule": "^1.0"
4343
},
4444
"suggest": {

src/WebauthnServiceProvider.php

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959
use Webauthn\PublicKeyCredentialLoader;
6060
use Webauthn\PublicKeyCredentialRpEntity;
6161
use Webauthn\PublicKeyCredentialSourceRepository;
62-
use Webauthn\TokenBinding\IgnoreTokenBindingHandler;
63-
use Webauthn\TokenBinding\TokenBindingHandler;
6462

6563
class WebauthnServiceProvider extends ServiceProvider
6664
{
@@ -138,7 +136,6 @@ public function registerResponseBindings()
138136
protected function bindWebAuthnPackage(): void
139137
{
140138
$this->app->bind(PublicKeyCredentialSourceRepository::class, CredentialRepository::class);
141-
$this->app->bind(TokenBindingHandler::class, IgnoreTokenBindingHandler::class);
142139

143140
$this->app->bind(
144141
PackedAttestationStatementSupport::class,
@@ -184,10 +181,11 @@ protected function bindWebAuthnPackage(): void
184181
);
185182
$this->app->bind(
186183
AttestationObjectLoader::class,
187-
fn ($app) => (new AttestationObjectLoader(
184+
fn ($app) => tap(new AttestationObjectLoader(
188185
$app[AttestationStatementSupportManager::class]
189-
))
190-
->setLogger($app['log'])
186+
), function ($loader) use ($app) {
187+
$loader->setLogger($app['log']);
188+
})
191189
);
192190

193191
$this->app->bind(
@@ -197,24 +195,26 @@ protected function bindWebAuthnPackage(): void
197195

198196
$this->app->bind(
199197
AuthenticatorAttestationResponseValidator::class,
200-
fn ($app) => (new AuthenticatorAttestationResponseValidator(
198+
fn ($app) => tap(new AuthenticatorAttestationResponseValidator(
201199
$app[AttestationStatementSupportManager::class],
202200
$app[PublicKeyCredentialSourceRepository::class],
203-
$app[TokenBindingHandler::class],
201+
null,
204202
$app[ExtensionOutputCheckerHandler::class]
205-
))
206-
->setLogger($app['log'])
203+
), function ($responseValidator) use ($app) {
204+
$responseValidator->setLogger($app['log']);
205+
})
207206
);
208207
$this->app->bind(
209208
AuthenticatorAssertionResponseValidator::class,
210-
fn ($app) => (new AuthenticatorAssertionResponseValidator(
209+
fn ($app) => tap(new AuthenticatorAssertionResponseValidator(
211210
$app[PublicKeyCredentialSourceRepository::class],
212-
$app[TokenBindingHandler::class],
211+
null,
213212
$app[ExtensionOutputCheckerHandler::class],
214213
$app[CoseAlgorithmManager::class]
215-
))
216-
->setCounterChecker($app[CounterChecker::class])
217-
->setLogger($app['log'])
214+
), function ($responseValidator) use ($app) {
215+
$responseValidator->setCounterChecker($app[CounterChecker::class])
216+
->setLogger($app['log']);
217+
})
218218
);
219219
$this->app->bind(
220220
AuthenticatorSelectionCriteria::class,
@@ -239,10 +239,11 @@ protected function bindWebAuthnPackage(): void
239239
);
240240
$this->app->bind(
241241
PublicKeyCredentialLoader::class,
242-
fn ($app) => (new PublicKeyCredentialLoader(
242+
fn ($app) => tap(new PublicKeyCredentialLoader(
243243
$app[AttestationObjectLoader::class]
244-
))
245-
->setLogger($app['log'])
244+
), function ($loader) use ($app) {
245+
$loader->setLogger($app['log']);
246+
})
246247
);
247248

248249
$this->app->bind(

tests/Unit/Models/Casts/Base64Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function it_deserialize_credentialId($credentialId, $expected)
2121
$this->assertEquals($expected, (new Base64)->set($webauthnKey, 'credentialId', $bin, []));
2222
}
2323

24-
public function dataProvider()
24+
public static function dataProvider()
2525
{
2626
return [
2727
[

tests/Unit/Services/WebauthnTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function test_do_authenticate()
127127
'origin' => 'https://localhost',
128128
'tokenBinding' => [
129129
'status' => 'supported',
130-
'id' => 'id',
130+
'id' => Base64UrlSafe::encodeUnpadded(1),
131131
],
132132
])),
133133
'authenticatorData' => Base64UrlSafe::encodeUnpadded(
@@ -148,7 +148,7 @@ public function test_do_authenticate()
148148
],
149149
];
150150

151-
$this->expectException(\Assert\InvalidArgumentException::class);
151+
$this->expectException(\InvalidArgumentException::class);
152152
$result = Webauthn::validateAssertion($user, $data);
153153

154154
$this->assertTrue($result); // Not yet ...
@@ -186,7 +186,7 @@ private function getAttestationData($publicKey)
186186
'origin' => 'https://localhost',
187187
'tokenBinding' => [
188188
'status' => 'supported',
189-
'id' => 'id',
189+
'id' => Base64UrlSafe::encodeUnpadded(1),
190190
],
191191
])),
192192
'attestationObject' => Base64UrlSafe::encodeUnpadded((string) (new MapObject([

0 commit comments

Comments
 (0)