31 lines
750 B
PHP
31 lines
750 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Foundation\PersonalAccessToken;
|
|
use Illuminate\Cache\RateLimiting\Limit;
|
|
use Illuminate\Support\Facades\RateLimiter;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Laravel\Sanctum\Sanctum;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void {}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
Sanctum::usePersonalAccessTokenModel(PersonalAccessToken::class);
|
|
|
|
RateLimiter::for('api', function ($request) {
|
|
$key = sha1($request->ip() . $request->header('User-Agent'));
|
|
return Limit::perMinute(10)->by($key);
|
|
});
|
|
}
|
|
}
|