98 lines
3.9 KiB
PHP
98 lines
3.9 KiB
PHP
<?php
|
|
|
|
namespace Paymenter\Extensions\Others\Security;
|
|
|
|
use Exception;
|
|
use App\Classes\Extension\Extension;
|
|
use Illuminate\Support\Facades\Artisan;
|
|
use Illuminate\Support\Facades\Event;
|
|
use Illuminate\Support\HtmlString;
|
|
|
|
use Paymenter\Extensions\Others\Security\Models\SuspendedAccount;
|
|
use Paymenter\Extensions\Others\Security\Models\BlockedIP;
|
|
use Paymenter\Extensions\Others\Security\Admin\Resources\SuspendedAccountResource;
|
|
use Paymenter\Extensions\Others\Security\Admin\Resources\BlockedIPResource;
|
|
use Paymenter\Extensions\Others\Security\Listeners\SecurityLoginListener;
|
|
|
|
class Security extends Extension
|
|
{
|
|
public function getConfig($values = [])
|
|
{
|
|
try {
|
|
return [
|
|
[
|
|
'name' => 'Notice',
|
|
'type' => 'placeholder',
|
|
'label' => new HtmlString(
|
|
'Use this extension to improve your security, manage account suspensions, block VPN/Proxy IPs and block IP addresses from logging in.
|
|
<br><br><small><i>Need support? Join our Discord at <a href="https://discord.gg/DP3atuhnsB">https://discord.gg/DP3atuhnsB</a></small></i>'
|
|
),
|
|
],
|
|
[
|
|
'name' => 'auto_suspend_fraud',
|
|
'type' => 'checkbox',
|
|
'label' => 'Auto-suspend accounts flagged for fraud',
|
|
'description' => 'Automatically suspend accounts when fraud is detected',
|
|
'default' => false,
|
|
],
|
|
[
|
|
'name' => 'block_vpn_ips',
|
|
'type' => 'checkbox',
|
|
'label' => 'Block known VPN/Proxy IPs',
|
|
'description' => 'Block login attempts from known VPN and proxy services',
|
|
'default' => false,
|
|
],
|
|
[
|
|
'name' => 'max_login_attempts',
|
|
'type' => 'number',
|
|
'label' => 'Max login attempts before IP block',
|
|
'description' => 'Number of failed login attempts before temporarily blocking IP',
|
|
'default' => 5,
|
|
],
|
|
[
|
|
'name' => 'ip_block_duration',
|
|
'type' => 'number',
|
|
'label' => 'IP block duration (minutes)',
|
|
'description' => 'How long to block an IP after max login attempts',
|
|
'default' => 60,
|
|
],
|
|
];
|
|
} catch (Exception $e) {
|
|
return [
|
|
[
|
|
'name' => 'Notice',
|
|
'type' => 'placeholder',
|
|
'label' => new HtmlString(
|
|
'You need to enable this extension before using it.
|
|
<br><br><small><i>Need support? Join our Discord at <a href="https://discord.gg/DP3atuhnsB">https://discord.gg/DP3atuhnsB</a></small></i>'
|
|
),
|
|
],
|
|
];
|
|
}
|
|
}
|
|
|
|
public function enabled()
|
|
{
|
|
Artisan::call('migrate', [
|
|
'--path' => 'extensions/Others/Security/database/migrations',
|
|
'--force' => true
|
|
]);
|
|
}
|
|
|
|
public function boot()
|
|
{
|
|
app('router')->aliasMiddleware('security.check', \Paymenter\Extensions\Others\Security\Middleware\SecurityCheck::class);
|
|
|
|
if (class_exists(\Filament\Filament::class)) {
|
|
\Filament\Filament::serving(function () {
|
|
\Filament\Filament::registerResources([
|
|
SuspendedAccountResource::class,
|
|
BlockedIPResource::class,
|
|
]);
|
|
});
|
|
}
|
|
|
|
Event::listen(\Illuminate\Auth\Events\Failed::class, [SecurityLoginListener::class, 'handleFailedLogin']);
|
|
}
|
|
}
|