From d1311a81e6737f87b04ecf6db3cdd9278b2e5067 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Tue, 10 Mar 2020 14:17:22 +0100 Subject: [PATCH] Remove pragmarx/firewall package --- .env.example | 2 - app/Http/Controllers/Admin/UserController.php | 4 - app/Http/Controllers/Auth/LoginController.php | 2 +- composer.json | 1 - composer.lock | 123 +------- config/firewall.php | 294 ------------------ 6 files changed, 2 insertions(+), 424 deletions(-) delete mode 100644 config/firewall.php diff --git a/.env.example b/.env.example index b59d0b775..7f8e1077e 100644 --- a/.env.example +++ b/.env.example @@ -136,8 +136,6 @@ SMARTY_COMPILE_CHECK=false SMARTY_FORCE_COMPILE=false SMARTY_CACHE_DRIVER=file -FIREWALL_ENABLED=false - IGDB_KEY= TMDB_APIKEY=9a4e16adddcd1e86da19bcaf5ff3c2a3 TMDB_CACHE=false diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 6d1714eb5..1c5b36df5 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -148,10 +148,6 @@ class UserController extends BasePageController User::updateUserRoleChangeDate($editedUser->id, $request->input('rolechangedate')); } if ($request->input('role') !== null) { - $roleName = Role::query()->where('id', $request->input('role'))->value('name'); - if (($roleName === 'Disabled') && config('firewall.enabled') === true && ! \Firewall::isBlacklisted($editedUser->host)) { - \Firewall::blacklist($editedUser->host); - } $editedUser->refresh(); SendAccountChangedEmail::dispatch($editedUser)->onQueue('emails'); } diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 5c15e31ba..aca183b89 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -79,7 +79,7 @@ class LoginController extends Controller $user = User::getByEmail($request->input('username')); } - if ($user !== null && ((config('firewall.enabled') === true && ! \Firewall::isBlacklisted($user->host)) || config('firewall.enabled') === false)) { + if ($user !== null) { if (config('captcha.enabled') === true && (! empty(config('captcha.secret')) && ! empty(config('captcha.sitekey')))) { $this->validate($request, [ 'g-recaptcha-response' => ['required', 'captcha'], diff --git a/composer.json b/composer.json index d036a2a4f..a15510740 100755 --- a/composer.json +++ b/composer.json @@ -136,7 +136,6 @@ "php-ffmpeg/php-ffmpeg": "^0.14", "php-http/guzzle6-adapter": "^1.1", "php-http/message": "^1.6", - "pragmarx/firewall": "^2.3", "predis/predis": "^1.1", "propaganistas/laravel-disposable-email": "^2.0", "ramsey/uuid": "^3.7", diff --git a/composer.lock b/composer.lock index e2daadc97..57bbcb22d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6e3be9d3ec4269bf299260c87892aa7b", + "content-hash": "79f82171de5c118807ff25a92308da9b", "packages": [ { "name": "aharen/omdbapi", @@ -5832,127 +5832,6 @@ ], "time": "2020-02-25T04:16:50+00:00" }, - { - "name": "pragmarx/firewall", - "version": "v2.3.0", - "source": { - "type": "git", - "url": "https://github.com/antonioribeiro/firewall.git", - "reference": "a631c8de757599053bf1ed6d9452a74bf9518be0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/antonioribeiro/firewall/zipball/a631c8de757599053bf1ed6d9452a74bf9518be0", - "reference": "a631c8de757599053bf1ed6d9452a74bf9518be0", - "shasum": "" - }, - "require": { - "illuminate/support": ">=5.3", - "php": ">=5.6", - "pragmarx/support": ">=0.8.0" - }, - "require-dev": { - "geoip2/geoip2": "~2.0", - "guzzlehttp/guzzle": "^6.2", - "orchestra/testbench": "3.4.*|3.5.*|3.6.*|3.7.*|3.8.*|4.*", - "phpunit/phpunit": "~7|~8" - }, - "suggest": { - "geoip/geoip": "~1.14", - "geoip2/geoip2": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.5.x-dev" - }, - "laravel": { - "providers": [ - "PragmaRX\\Firewall\\Vendor\\Laravel\\ServiceProvider" - ], - "aliases": { - "Firewall": "PragmaRX\\Firewall\\Vendor\\Laravel\\Facade" - } - } - }, - "autoload": { - "psr-4": { - "PragmaRX\\Firewall\\": "src/", - "PragmaRX\\Firewall\\Tests\\": "tests/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Antonio Carlos Ribeiro", - "email": "acr@antoniocarlosribeiro.com", - "role": "Creator" - } - ], - "description": "A Laravel IP whitelisting and blacklisting", - "keywords": [ - "blacklist", - "firewall", - "laravel", - "whitelist" - ], - "time": "2019-09-11T17:32:48+00:00" - }, - { - "name": "pragmarx/support", - "version": "v0.9.0", - "source": { - "type": "git", - "url": "https://github.com/antonioribeiro/support.git", - "reference": "97d12bc8d29c35a509973f8f898f3d4d1eaf3777" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/antonioribeiro/support/zipball/97d12bc8d29c35a509973f8f898f3d4d1eaf3777", - "reference": "97d12bc8d29c35a509973f8f898f3d4d1eaf3777", - "shasum": "" - }, - "require": { - "illuminate/filesystem": "~4.0|~5.0|~6.0", - "php": ">=5.4.0", - "symfony/var-dumper": "~2.6|~3.0|~4.0" - }, - "suggest": { - "laravel/framework": "Laravel framework.", - "symfony/yaml": "The Yaml class needs it" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.7.x-dev" - } - }, - "autoload": { - "psr-4": { - "PragmaRX\\Support\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Antonio Carlos Ribeiro", - "email": "acr@antoniocarlosribeiro.com", - "role": "Creator" - } - ], - "description": "PragmaRX components support package", - "keywords": [ - "laravel", - "pragmarx" - ], - "time": "2019-09-10T21:17:26+00:00" - }, { "name": "predis/predis", "version": "v1.1.1", diff --git a/config/firewall.php b/config/firewall.php deleted file mode 100644 index 812582210..000000000 --- a/config/firewall.php +++ /dev/null @@ -1,294 +0,0 @@ - env('FIREWALL_ENABLED', true), - - /* - * Whitelisted and blacklisted IP addresses, ranges, countries, files and/or files of files - * - * Examples of IP address, hosts, country codes and CIDRs - * '127.0.0.1', - * '192.168.17.0/24' - * '127.0.0.1/255.255.255.255' - * '10.0.0.1-10.0.0.255' - * '172.17.*.*' - * 'country:br' - * 'host:google.com', - * storage_path().DIRECTORY_SEPARATOR.'blacklisted.txt', // a file with IPs, one per line - */ - - 'blacklist' => [ - ], - - 'whitelist' => [ - ], - - /* - * Response action for blocked responses - * - */ - - 'responses' => [ - 'blacklist' => [ - 'code' => 403, // 200 = log && notify, but keep pages rendering - - 'message' => null, - - 'view' => null, - - 'redirect_to' => null, - - 'abort' => false, // return abort() instead of Response::make() - disabled by default - ], - - 'whitelist' => [ - 'code' => 403, // 200 = log && notify, but keep pages rendering - - 'message' => null, - - 'view' => null, - - 'redirect_to' => null, - - 'abort' => false, // return abort() instead of Response::make() - disabled by default - ], - ], - - /* - * Do you wish to redirect non whitelisted accesses to an error page? - * - * You can use a route name (coming.soon) or url (/coming/soon); - * - */ - - 'redirect_non_whitelisted_to' => null, - - /* - * How long should we keep IP addresses in cache? - * - * This is a general client IP addresses cache. When the user hits your ssytem his/her IP address - * is searched and cached for the desired time. Finding an IP address contained in a CIDR - * range (172.17.0.0/24, for instance) can be a "slow", caching it improves performance. - * - */ - - 'cache_expire_time' => 60, // minutes - - /* - * How long should we keep lists of IP addresses in cache? - * - * This is the list cache. Database lists can take some time to load and process, - * caching it, if you are not making frequent changes to your lists, may improve firewall speed a lot. - */ - - 'ip_list_cache_expire_time' => 0, // minutes - disabled by default - - /* - * Send suspicious events to log? - * - */ - - 'enable_log' => true, - - /* - * Search by range allow you to store ranges of addresses in - * your black and whitelist: - * - * 192.168.17.0/24 or - * 127.0.0.1/255.255.255.255 or - * 10.0.0.1-10.0.0.255 or - * 172.17.*.* - * - * Note that range searches may be slow and waste memory, this is why - * it is disabled by default. - * - */ - - 'enable_range_search' => true, - - /* - * Search by country range allow you to store country ids in your - * your black and whitelist: - * - * php artisan firewall:whitelist country:us - * php artisan firewall:blacklist country:cn - * - */ - - 'enable_country_search' => true, - - /* - * Should Firewall use the database? - */ - - 'use_database' => true, - - /* - * Models - * - * When using the "eloquent" driver, we need to know which Eloquent models - * should be used. - * - */ - - 'firewall_model' => 'PragmaRX\Firewall\Vendor\Laravel\Models\Firewall', - - /* - * Session object binding in the IoC Container - * - * When blacklisting IPs for the current session, Firewall - * will need to instantiate the session object. - * - */ - - 'session_binding' => 'session', - - /* - * GeoIp2 database path. - * - * To get a fresh version of this file, use the command - * - * php artisan firewall:updategeoip - * - */ - - 'geoip_database_path' => __DIR__.'/geoip', //storage_path('geoip'), - - /* - * Block suspicious attacks - */ - - 'attack_blocker' => [ - - 'enabled' => [ - 'ip' => true, - - 'country' => false, - ], - - 'cache_key_prefix' => 'firewall-attack-blocker', - - 'allowed_frequency' => [ - - 'ip' => [ - 'requests' => 10, - - 'seconds' => 1 * 60, // 1 minute - ], - - 'country' => [ - 'requests' => 3000, - - 'seconds' => 2 * 60, // 2 minutes - ], - - ], - - 'action' => [ - - 'ip' => [ - 'blacklist_unknown' => true, - - 'blacklist_whitelisted' => false, - ], - - 'country' => [ - 'blacklist_unknown' => false, - - 'blacklist_whitelisted' => false, - ], - - ], - - 'response' => [ - 'code' => 403, // 200 = log && notify, but keep pages rendering - - 'message' => null, - - 'view' => null, - - 'redirect_to' => null, - - 'abort' => false, // return abort() instead of Response::make() - disabled by default - ], - - ], - - 'notifications' => [ - 'enabled' => true, - - 'message' => [ - 'title' => 'User agent', - - 'message' => "A possible attack on '%s' has been detected from %s", - - 'request_count' => [ - 'title' => 'Request count', - - 'message' => 'Received %s requests in the last %s seconds. Timestamp of first request: %s', - ], - - 'uri' => [ - 'title' => 'First URI offended', - ], - - 'blacklisted' => [ - 'title' => 'Was it blacklisted?', - ], - - 'user_agent' => [ - 'title' => 'User agent', - ], - - 'geolocation' => [ - 'title' => 'Geolocation', - - 'field_latitude' => 'Latitude', - - 'field_longitude' => 'Longitude', - - 'field_country_code' => 'Country code', - - 'field_country_name' => 'Country name', - - 'field_city' => 'City', - ], - ], - - 'route' => '', - - 'from' => [ - 'name' => 'Laravel Firewall', - - 'address' => 'firewall@mydomain.com', - - 'icon_emoji' => ':fire:', - ], - - 'users' => [ - 'model' => PragmaRX\Firewall\Vendor\Laravel\Models\User::class, - - 'emails' => [ - config('nntmux.admin_email'), - ], - ], - - 'channels' => [ - 'slack' => [ - 'enabled' => false, - 'sender' => PragmaRX\Firewall\Notifications\Channels\Slack::class, - ], - - 'mail' => [ - 'enabled' => true, - 'sender' => PragmaRX\Firewall\Notifications\Channels\Mail::class, - ], - ], - ], -];