You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You'll need a [`psr/http-factory-implementation` implementation](https://packagist.org/providers/psr/http-factory-implementation):
60
-
61
-
We recommend using `guzzlehttp/psr7`, which is installed by `guzzlehttp/guzzle`, so you probably already have it.
62
-
63
-
You can use any other [`psr/http-factory-implementation` implementation](https://packagist.org/providers/psr/http-factory-implementation), like `nyholm/psr7` (this one also requires `symfony/psr-http-message-bridge` and `php-http/discovery`)
64
-
65
56
## Configuration
66
57
67
58
You can publish LaravelWebauthn configuration in a file named `config/webauthn.php`, and resources using the `vendor:publish` command:
@@ -79,48 +70,48 @@ php artisan migrate
79
70
80
71
# Set Up
81
72
82
-
## Add LaravelWebauthn middleware
73
+
## Option 1: add LaravelWebauthn middleware
83
74
84
75
The Webauthn middleware will force the user to authenticate their webauthn key for certain routes.
85
76
86
-
Add this in the `$routeMiddleware` array of your `app/Http/Kernel.php` file:
77
+
Assign the middleware to a route or a group of routes:
The Webauthn middleware will redirect the user to the webauthn login page when required.
101
88
102
89
103
-
## Login via remember
90
+
###Login via remember
104
91
105
-
When session expires, but the user have set the `remember` cookie, you can revalidate webauthn session by adding this in your `App\Providers\EventServiceProvider` file:
92
+
When session expires, but the user have set the `remember` cookie, you can revalidate webauthn session by subscribing to the `LaravelWebauthn\Listeners\LoginViaRemember` listener:
106
93
107
94
```php
108
-
use Illuminate\Auth\Events\Login;
109
-
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
110
-
use LaravelWebauthn\Listeners\LoginViaRemember;
95
+
use Illuminate\Support\Facades\Event;
96
+
use Illuminate\Support\ServiceProvider;
111
97
112
-
class EventServiceProvider extends ServiceProvider
By default, Laravel Webauthn will throttle logins to five requests per minute for every email and IP address combination. You may specify a custom rate limiter with other specifications.
339
333
340
-
First define a custom rate limiter. Follow [Laravel rate limiter documentation](https://laravel.com/docs/9.x/routing#defining-rate-limiters) to create a new RateLimiter within the `configureRateLimiting` method of your application's `App\Providers\RouteServiceProvider` class.
334
+
First define a custom rate limiter. Follow [Laravel rate limiter documentation](https://laravel.com/docs/11.x/routing#defining-rate-limiters) to create a new RateLimiter within the `boot` method of your application's `App\Providers\AppServiceProvider` class.
341
335
342
336
```php
343
337
use Illuminate\Cache\RateLimiting\Limit;
338
+
use Illuminate\Http\Request;
344
339
use Illuminate\Support\Facades\RateLimiter;
340
+
use Illuminate\Support\ServiceProvider;
345
341
346
-
/**
347
-
* Configure the rate limiters for the application.
348
-
*
349
-
* @return void
350
-
*/
351
-
protected function configureRateLimiting()
342
+
class AppServiceProvider extends ServiceProvider
352
343
{
353
-
RateLimiter::for('webauthn-login', function (Request $request) {
354
-
return Limit::perMinute(1000);
355
-
});
344
+
/**
345
+
* Bootstrap any application services.
346
+
*/
347
+
protected function boot(): void
348
+
{
349
+
RateLimiter::for('webauthn-login', function (Request $request) {
350
+
return Limit::perMinute(1000);
351
+
});
352
+
}
356
353
}
357
354
```
358
355
@@ -379,14 +376,17 @@ Events are dispatched by LaravelWebauthn:
379
376
380
377
You can easily change the view responses with the Webauthn service.
381
378
382
-
For instance, call `Webauthn::loginViewResponseUsing`in your `AppServiceProvider`:
379
+
For instance, call `Webauthn::loginViewResponseUsing`in your `App\Providers\AppServiceProvider` class:
0 commit comments