Skip to content

Commit 1a4eaca

Browse files
authored
feat!: Support Laravel 12 and webauthn-lib 5.0+ (#497)
BREAKING CHANGES: - The `Webauthn::prepareAssertion` and `Webauthn::prepareAttestation` methods now return `LaravelWebauthn\Services\Webauthn\PublicKeyCredentialRequestOptionsRequest` and `LaravelWebauthn\Services\Webauthn\PublicKeyCredentialCreationOptionsRequest` respectively, and this impacts all classes that rely on it. - `EloquentWebAuthnProvider`: removes `validator` parameter - `OptionsFactory`: removes `repository` parameter - The user_verification setting was previously forced to `required` when `webauthn.userless` config was set to `preferred` or `required`. It nows only relies on the `webauthn.user_verification` config. See [migration-v4-to-v5](https://github.com/asbiin/laravel-webauthn/blob/main/docs/migration-v4-to-v5.md) page.
1 parent ba8037d commit 1a4eaca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+357
-182
lines changed

.github/workflows/static.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ jobs:
1313
name: Static analysis
1414
uses: monicahq/workflows/.github/workflows/static.yml@v2
1515
with:
16-
php-version: 8.2
16+
php-version: 8.4

.github/workflows/tests.yml

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ on:
1616
workflow_dispatch:
1717

1818
env:
19-
default-php-version: '8.3'
20-
default-laravel-version: '11.0'
21-
semantic-node-version: 20
19+
default-php-version: '8.4'
20+
default-laravel-version: '12.0'
21+
semantic-node-version: 22
2222

2323
concurrency:
2424
group: Tests ${{ github.ref }}
@@ -32,22 +32,10 @@ jobs:
3232
strategy:
3333
fail-fast: false
3434
matrix:
35-
php-version: ['8.1', '8.2', '8.3']
36-
laravel-version: ['9.0', '10.0', '11.0']
35+
php-version: ['8.2', '8.3', '8.4']
36+
laravel-version: ['11.0', '12.0']
3737
psr7: ['guzzle']
3838
include:
39-
- php-version: '8.1'
40-
laravel-version: '9.0'
41-
psr7: 'nyholm'
42-
- php-version: '8.1'
43-
laravel-version: '9.0'
44-
psr7: 'discovery'
45-
- php-version: '8.2'
46-
laravel-version: '10.0'
47-
psr7: 'nyholm'
48-
- php-version: '8.2'
49-
laravel-version: '10.0'
50-
psr7: 'discovery'
5139
- php-version: '8.2'
5240
laravel-version: '11.0'
5341
psr7: 'nyholm'
@@ -60,9 +48,12 @@ jobs:
6048
- php-version: '8.3'
6149
laravel-version: '11.0'
6250
psr7: 'discovery'
63-
exclude:
64-
- php-version: '8.1'
65-
laravel-version: '11.0'
51+
- php-version: '8.4'
52+
laravel-version: '12.0'
53+
psr7: 'nyholm'
54+
- php-version: '8.4'
55+
laravel-version: '12.0'
56+
psr7: 'discovery'
6657

6758
steps:
6859
- name: Checkout sources
@@ -183,7 +174,7 @@ jobs:
183174
184175
- name: SonarCloud Scan
185176
if: env.SONAR_TOKEN != ''
186-
uses: SonarSource/sonarqube-scan-action@v4
177+
uses: SonarSource/sonarqube-scan-action@v5
187178
env:
188179
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
189180
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ To enable passwordless authentication, first add the webauthn user provider: upd
129129
Then allow your login page to initiate a webauthn login with an `email` identifier.
130130

131131
You can call `webauthn.auth.options` route with a POST request and an `email` input to get the challenge data.
132-
See [authentication](#Authenticate) section for more details.
132+
See [Authenticate](#Authenticate) section for more details.
133133

134134

135135
## Disabling Views
@@ -427,11 +427,12 @@ List of methods and their expected response contracts:
427427

428428
This package has the following Laravel compatibility:
429429

430-
| Laravel | [asbiin/laravel-webauthn](https://github.com/asbiin/laravel-webauthn) |
430+
| [asbiin/laravel-webauthn](https://github.com/asbiin/laravel-webauthn) | Laravel |
431431
|----------|----------|
432-
| 5.8-8.x | <= 1.2.0 |
433-
| 7.x-8.x | 2.0.1 |
434-
| >= 9.x | >= 3.0.0 |
432+
| <= 1.2.0 | 5.8-8.x |
433+
| 2.0.1 | 7.x-8.x |
434+
| >= 3.0.0, <= 4.6.0 | 9.x-11.x |
435+
| >= 5.0.0 | >= 11.x |
435436

436437
## Browser compatibility
437438

@@ -466,6 +467,6 @@ If you haven't done so already, describe your site domain and network in your ho
466467

467468
Author: [Alexis Saettler](https://github.com/asbiin)
468469

469-
Copyright © 20192024.
470+
Copyright © 20192025.
470471

471472
Licensed under the MIT License. [View license](/LICENSE.md).

composer.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,34 @@
2020
}
2121
],
2222
"require": {
23-
"php": ">=8.1",
24-
"illuminate/support": "^9.0 || ^10.0 || ^11.0",
23+
"php": ">=8.2",
24+
"illuminate/support": "^11.0 || ^12.0",
2525
"phpdocumentor/reflection-docblock": "^5.3",
2626
"psr/http-factory-implementation": "1.0",
2727
"symfony/property-access": "^6.4 || ^7.0",
2828
"symfony/property-info": "^6.4 || ^7.0",
2929
"symfony/serializer": "^6.4 || ^7.0",
3030
"web-auth/cose-lib": "^4.0",
31-
"web-auth/webauthn-lib": "^4.8",
32-
"web-token/jwt-library": "^3.0"
31+
"web-auth/webauthn-lib": "^4.8 || ^5.0",
32+
"web-token/jwt-library": "^3.0 || ^4.0"
3333
},
3434
"conflict": {
3535
"web-auth/webauthn-lib": "4.7.0"
3636
},
3737
"require-dev": {
3838
"ext-sqlite3": "*",
39+
"brainmaestro/composer-git-hooks": "^3.0",
3940
"guzzlehttp/psr7": "^2.1",
40-
"jschaedl/composer-git-hooks": "^4.0",
41-
"larastan/larastan": "^2.0",
41+
"larastan/larastan": "^2.0 || ^3.0",
4242
"laravel/legacy-factories": "^1.0",
4343
"laravel/pint": "^1.13",
4444
"ocramius/package-versions": "^2.0",
45-
"orchestra/testbench": "^7.0 || ^8.0 || ^9.0",
46-
"phpstan/phpstan-deprecation-rules": "^1.0",
47-
"phpstan/phpstan-phpunit": "^1.0",
48-
"phpstan/phpstan-strict-rules": "^1.0",
49-
"phpunit/phpunit": "^9.5 || ^10.0 || ^11.0",
50-
"psalm/plugin-laravel": "^2.8"
45+
"orchestra/testbench": "^9.0 || ^10.0",
46+
"phpstan/phpstan-deprecation-rules": "^1.0 || ^2.0",
47+
"phpstan/phpstan-phpunit": "^1.0 || ^2.0",
48+
"phpstan/phpstan-strict-rules": "^1.0 || ^2.0",
49+
"phpunit/phpunit": "^10.0 || ^11.0 || ^12.0",
50+
"psalm/plugin-laravel": "^2.8 || ^3.0"
5151
},
5252
"suggest": {
5353
"guzzlehttp/psr7": "To provide a psr/http-factory-implementation implementation",

config/webauthn.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,6 @@
277277
| ID to use for authentication, but they can also login without specifying
278278
| one if the device can remember them, allowing for true one-touch login.
279279
|
280-
| If required or preferred, login verification will be always required.
281-
|
282280
| See https://www.w3.org/TR/webauthn/#enum-residentKeyRequirement
283281
|
284282
| Supported: "null", "required", "preferred", "discouraged".

database/migrations/2019_03_29_163611_add_webauthn.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Illuminate\Database\Schema\Blueprint;
77
use Illuminate\Support\Facades\Schema;
88

9-
return new class() extends Migration
9+
return new class extends Migration
1010
{
1111
/**
1212
* Run the migrations.

docs/migration-v4-to-v5.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Migration from v4 to v5
2+
3+
V5 of Webauthn introduces multiple breaking changes:
4+
5+
## Classes and Interfaces
6+
7+
The [`Webauthn\PublicKeyCredentialRequestOptions`](https://github.com/web-auth/webauthn-framework/blob/5.2.x/src/webauthn/src/PublicKeyCredentialRequestOptions.php) and [`Webauthn\PublicKeyCredentialCreationOptions`](https://github.com/web-auth/webauthn-framework/blob/5.2.x/src/webauthn/src/PublicKeyCredentialCreationOptions.php) classes from webauthn-lib no longer implement the `JsonSerializable` interface. This means that the `jsonSerialize` method is no longer available. Instead, the `Webauthn\PublicKeyCredentialRequestOptions` and `Webauthn\PublicKeyCredentialCreationOptions` classes have been replaced by `LaravelWebauthn\Services\Webauthn\PublicKeyCredentialRequestOptionsRequest` and `LaravelWebauthn\Services\Webauthn\PublicKeyCredentialCreationOptionsRequest` classes, which do implement the `JsonSerializable` interface and help serializing it for Laravel.
8+
9+
The `Webauthn::prepareAssertion` and `Webauthn::prepareAttestation` methods now return `LaravelWebauthn\Services\Webauthn\PublicKeyCredentialRequestOptionsRequest` and `LaravelWebauthn\Services\Webauthn\PublicKeyCredentialCreationOptionsRequest` respectively, and this impacts all classes that rely on it.
10+
11+
This change impacts:
12+
* `LaravelWebauthn\Actions\PrepareAssertionData`
13+
* `LaravelWebauthn\Actions\PrepareCreationData`
14+
* `LaravelWebauthn\Contracts\LoginViewResponse`
15+
* `LaravelWebauthn\Contracts\RegisterViewResponse`
16+
* `LaravelWebauthn\Services\Webauthn\CreationOptionsFactory`
17+
* `LaravelWebauthn\Services\Webauthn\RequestOptionsFactory`
18+
* `LaravelWebauthn\Services\Webauthn`
19+
20+
To implement the change, just replace
21+
```php
22+
use Webauthn\PublicKeyCredentialRequestOptions;
23+
```
24+
25+
with
26+
```php
27+
use LaravelWebauthn\Services\Webauthn\PublicKeyCredentialRequestOptions;
28+
```
29+
30+
and
31+
```php
32+
use Webauthn\PublicKeyCredentialCreationOptions;
33+
```
34+
35+
with
36+
```php
37+
use LaravelWebauthn\Services\Webauthn\PublicKeyCredentialCreationOptions;
38+
```
39+
40+
41+
## User Verification
42+
43+
The user_verification setting was previously forced to `required` when `webauthn.userless` config was set to `preferred` or `required`. It nows only relies on the `webauthn.user_verification` config.
44+
45+
46+
## Simplications
47+
48+
* `EloquentWebAuthnProvider` constructor: removes `validator` parameter
49+
* `OptionsFactory`: removes `repository` parameter

phpstan.neon

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,3 @@ parameters:
1616
paths:
1717
- */Actions/AttemptToAuthenticate.php
1818
- */Services/Webauthn/CreationOptionsFactory.php
19-
20-
excludes_analyse:

psalm.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@
1717
<plugins>
1818
<pluginClass class="Psalm\LaravelPlugin\Plugin"/>
1919
</plugins>
20+
21+
<issueHandlers>
22+
<PossiblyUnusedMethod errorLevel="suppress"/>
23+
</issueHandlers>
2024
</psalm>

src/Actions/PrepareAssertionData.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Illuminate\Contracts\Auth\Authenticatable as User;
66
use LaravelWebauthn\Facades\Webauthn;
7-
use Webauthn\PublicKeyCredentialRequestOptions;
7+
use LaravelWebauthn\Services\Webauthn\PublicKeyCredentialRequestOptions;
88

99
class PrepareAssertionData
1010
{

0 commit comments

Comments
 (0)