37 lines
953 B
PHP
37 lines
953 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Customer;
|
|
use App\Models\IpPool;
|
|
use App\Models\User;
|
|
use App\Policies\IpPoolPolicy;
|
|
use App\Policies\UserPolicy;
|
|
use App\Policies\VmPolicy;
|
|
use Illuminate\Cache\RateLimiting\Limit;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Support\Facades\RateLimiter;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
public function boot(): void
|
|
{
|
|
RateLimiter::for('login', function (Request $request) {
|
|
$max = (int) config('hosting.security.login_max_attempts', 5);
|
|
|
|
return Limit::perMinute($max)->by($request->ip().'|'.$request->input('email'));
|
|
});
|
|
|
|
Gate::policy(Customer::class, VmPolicy::class);
|
|
Gate::policy(IpPool::class, IpPoolPolicy::class);
|
|
Gate::policy(User::class, UserPolicy::class);
|
|
}
|
|
}
|