From 1efd49607fe0773525811e65f73ca988c0496244 Mon Sep 17 00:00:00 2001 From: f4ilji Date: Thu, 21 Nov 2024 00:25:35 +0500 Subject: [PATCH] Changes --- app/Models/User.php | 8 +- app/Providers/EventServiceProvider.php | 9 + app/Providers/Filament/AdminPanelProvider.php | 2 + composer.json | 2 + composer.lock | 370 +++++++++++++++++- vite.config.js | 3 + 6 files changed, 391 insertions(+), 3 deletions(-) diff --git a/app/Models/User.php b/app/Models/User.php index 926ba9d..9f77dc5 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -12,12 +12,14 @@ use Filament\Tables\Columns\Layout\Panel; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; +use Laravel\Fortify\TwoFactorAuthenticatable; use Laravel\Sanctum\HasApiTokens; use Spatie\Permission\Traits\HasRoles; +use Vormkracht10\TwoFactorAuth\Enums\TwoFactorType; class User extends Authenticatable implements FilamentUser { - use HasApiTokens, HasFactory, Notifiable, HasRoles, HasPanelShield; + use HasApiTokens, HasFactory, Notifiable, HasRoles, HasPanelShield, TwoFactorAuthenticatable; /** * The attributes that are mass assignable. @@ -28,7 +30,8 @@ class User extends Authenticatable implements FilamentUser 'name', 'email', 'password', - 'slug' + 'slug', + 'two_factor_type' ]; /** @@ -49,6 +52,7 @@ class User extends Authenticatable implements FilamentUser protected $casts = [ 'email_verified_at' => 'datetime', 'password' => 'hashed', + 'two_factor_type' => TwoFactorType::class, ]; public function userDetail() diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index eeb249a..b150479 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -8,6 +8,9 @@ use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Listeners\SendEmailVerificationNotification; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use Illuminate\Support\Facades\Event; +use Laravel\Fortify\Events\TwoFactorAuthenticationChallenged; +use Laravel\Fortify\Events\TwoFactorAuthenticationEnabled; +use Vormkracht10\TwoFactorAuth\Listeners\SendTwoFactorCodeListener; class EventServiceProvider extends ServiceProvider { @@ -20,6 +23,12 @@ class EventServiceProvider extends ServiceProvider Registered::class => [ SendEmailVerificationNotification::class, ], + TwoFactorAuthenticationChallenged::class => [ + SendTwoFactorCodeListener::class, + ], + TwoFactorAuthenticationEnabled::class => [ + SendTwoFactorCodeListener::class, + ], ]; /** diff --git a/app/Providers/Filament/AdminPanelProvider.php b/app/Providers/Filament/AdminPanelProvider.php index 2081daf..a85cf6c 100644 --- a/app/Providers/Filament/AdminPanelProvider.php +++ b/app/Providers/Filament/AdminPanelProvider.php @@ -20,6 +20,7 @@ use Illuminate\Session\Middleware\AuthenticateSession; use Illuminate\Session\Middleware\StartSession; use Illuminate\View\Middleware\ShareErrorsFromSession; use ShuvroRoy\FilamentSpatieLaravelBackup\FilamentSpatieLaravelBackupPlugin; +use Vormkracht10\TwoFactorAuth\TwoFactorAuthPlugin; class AdminPanelProvider extends PanelProvider @@ -64,6 +65,7 @@ class AdminPanelProvider extends PanelProvider \BezhanSalleh\FilamentShield\FilamentShieldPlugin::make(), FilamentSpatieLaravelBackupPlugin::make()->usingPage(Backups::class), CheckpointPlugin::make(), + TwoFactorAuthPlugin::make()->forced(), ]); } } diff --git a/composer.json b/composer.json index 2dc7b61..f02f5e8 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "inertiajs/inertia-laravel": "^1.3", "intervention/image": "^2.7", "joshembling/image-optimizer": "^1.4", + "laravel/fortify": "^1.24", "laravel/framework": "^10.10", "laravel/sanctum": "^3.2", "laravel/tinker": "^2.8", @@ -29,6 +30,7 @@ "symfony/filesystem": "^6.3", "tightenco/ziggy": "^1.0", "vkcom/vk-php-sdk": "^5.131", + "vormkracht10/filament-2fa": "^2.0", "xvladqt/faker-lorem-flickr": "^1.0" }, "require-dev": { diff --git a/composer.lock b/composer.lock index c31cada..d69c074 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": "892ae9703ae6b3f7c6f19bac3a774d06", + "content-hash": "f9f711e2f5b1030fd1be472f64fe1271", "packages": [ { "name": "anourvalar/eloquent-serialize", @@ -217,6 +217,60 @@ ], "time": "2024-09-21T17:01:40+00:00" }, + { + "name": "bacon/bacon-qr-code", + "version": "v3.0.1", + "source": { + "type": "git", + "url": "https://github.com/Bacon/BaconQrCode.git", + "reference": "f9cc1f52b5a463062251d666761178dbdb6b544f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Bacon/BaconQrCode/zipball/f9cc1f52b5a463062251d666761178dbdb6b544f", + "reference": "f9cc1f52b5a463062251d666761178dbdb6b544f", + "shasum": "" + }, + "require": { + "dasprid/enum": "^1.0.3", + "ext-iconv": "*", + "php": "^8.1" + }, + "require-dev": { + "phly/keep-a-changelog": "^2.12", + "phpunit/phpunit": "^10.5.11 || 11.0.4", + "spatie/phpunit-snapshot-assertions": "^5.1.5", + "squizlabs/php_codesniffer": "^3.9" + }, + "suggest": { + "ext-imagick": "to generate QR code images" + }, + "type": "library", + "autoload": { + "psr-4": { + "BaconQrCode\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Ben Scholzen 'DASPRiD'", + "email": "mail@dasprids.de", + "homepage": "https://dasprids.de/", + "role": "Developer" + } + ], + "description": "BaconQrCode is a QR code generator for PHP.", + "homepage": "https://github.com/Bacon/BaconQrCode", + "support": { + "issues": "https://github.com/Bacon/BaconQrCode/issues", + "source": "https://github.com/Bacon/BaconQrCode/tree/v3.0.1" + }, + "time": "2024-10-01T13:55:55+00:00" + }, { "name": "bezhansalleh/filament-shield", "version": "3.2.6", @@ -822,6 +876,56 @@ ], "time": "2024-05-06T09:10:03+00:00" }, + { + "name": "dasprid/enum", + "version": "1.0.6", + "source": { + "type": "git", + "url": "https://github.com/DASPRiD/Enum.git", + "reference": "8dfd07c6d2cf31c8da90c53b83c026c7696dda90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/DASPRiD/Enum/zipball/8dfd07c6d2cf31c8da90c53b83c026c7696dda90", + "reference": "8dfd07c6d2cf31c8da90c53b83c026c7696dda90", + "shasum": "" + }, + "require": { + "php": ">=7.1 <9.0" + }, + "require-dev": { + "phpunit/phpunit": "^7 || ^8 || ^9 || ^10 || ^11", + "squizlabs/php_codesniffer": "*" + }, + "type": "library", + "autoload": { + "psr-4": { + "DASPRiD\\Enum\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Ben Scholzen 'DASPRiD'", + "email": "mail@dasprids.de", + "homepage": "https://dasprids.de/", + "role": "Developer" + } + ], + "description": "PHP 7.1 enum implementation", + "keywords": [ + "enum", + "map" + ], + "support": { + "issues": "https://github.com/DASPRiD/Enum/issues", + "source": "https://github.com/DASPRiD/Enum/tree/1.0.6" + }, + "time": "2024-08-09T14:30:48+00:00" + }, { "name": "dflydev/dot-access-data", "version": "v3.0.3", @@ -3091,6 +3195,71 @@ }, "time": "2024-10-06T12:28:14+00:00" }, + { + "name": "laravel/fortify", + "version": "v1.24.5", + "source": { + "type": "git", + "url": "https://github.com/laravel/fortify.git", + "reference": "bba8c2ecc3fcc78e8632e0d719ae10bef6343eef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/fortify/zipball/bba8c2ecc3fcc78e8632e0d719ae10bef6343eef", + "reference": "bba8c2ecc3fcc78e8632e0d719ae10bef6343eef", + "shasum": "" + }, + "require": { + "bacon/bacon-qr-code": "^3.0", + "ext-json": "*", + "illuminate/support": "^10.0|^11.0", + "php": "^8.1", + "pragmarx/google2fa": "^8.0", + "symfony/console": "^6.0|^7.0" + }, + "require-dev": { + "mockery/mockery": "^1.0", + "orchestra/testbench": "^8.16|^9.0", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^10.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + }, + "laravel": { + "providers": [ + "Laravel\\Fortify\\FortifyServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Laravel\\Fortify\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "Backend controllers and scaffolding for Laravel authentication.", + "keywords": [ + "auth", + "laravel" + ], + "support": { + "issues": "https://github.com/laravel/fortify/issues", + "source": "https://github.com/laravel/fortify" + }, + "time": "2024-11-12T14:51:12+00:00" + }, { "name": "laravel/framework", "version": "v10.48.24", @@ -5328,6 +5497,73 @@ ], "time": "2024-09-24T14:04:43+00:00" }, + { + "name": "paragonie/constant_time_encoding", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/paragonie/constant_time_encoding.git", + "reference": "df1e7fde177501eee2037dd159cf04f5f301a512" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/df1e7fde177501eee2037dd159cf04f5f301a512", + "reference": "df1e7fde177501eee2037dd159cf04f5f301a512", + "shasum": "" + }, + "require": { + "php": "^8" + }, + "require-dev": { + "phpunit/phpunit": "^9", + "vimeo/psalm": "^4|^5" + }, + "type": "library", + "autoload": { + "psr-4": { + "ParagonIE\\ConstantTime\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com", + "role": "Maintainer" + }, + { + "name": "Steve 'Sc00bz' Thomas", + "email": "steve@tobtu.com", + "homepage": "https://www.tobtu.com", + "role": "Original Developer" + } + ], + "description": "Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)", + "keywords": [ + "base16", + "base32", + "base32_decode", + "base32_encode", + "base64", + "base64_decode", + "base64_encode", + "bin2hex", + "encoding", + "hex", + "hex2bin", + "rfc4648" + ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/constant_time_encoding/issues", + "source": "https://github.com/paragonie/constant_time_encoding" + }, + "time": "2024-05-08T12:36:18+00:00" + }, { "name": "phpdocumentor/reflection-common", "version": "2.2.0", @@ -5666,6 +5902,58 @@ }, "time": "2024-10-13T11:29:49+00:00" }, + { + "name": "pragmarx/google2fa", + "version": "v8.0.3", + "source": { + "type": "git", + "url": "https://github.com/antonioribeiro/google2fa.git", + "reference": "6f8d87ebd5afbf7790bde1ffc7579c7c705e0fad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/antonioribeiro/google2fa/zipball/6f8d87ebd5afbf7790bde1ffc7579c7c705e0fad", + "reference": "6f8d87ebd5afbf7790bde1ffc7579c7c705e0fad", + "shasum": "" + }, + "require": { + "paragonie/constant_time_encoding": "^1.0|^2.0|^3.0", + "php": "^7.1|^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.9", + "phpunit/phpunit": "^7.5.15|^8.5|^9.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "PragmaRX\\Google2FA\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Antonio Carlos Ribeiro", + "email": "acr@antoniocarlosribeiro.com", + "role": "Creator & Designer" + } + ], + "description": "A One Time Password Authentication package, compatible with Google Authenticator.", + "keywords": [ + "2fa", + "Authentication", + "Two Factor Authentication", + "google2fa" + ], + "support": { + "issues": "https://github.com/antonioribeiro/google2fa/issues", + "source": "https://github.com/antonioribeiro/google2fa/tree/v8.0.3" + }, + "time": "2024-09-05T11:56:40+00:00" + }, { "name": "protonemedia/laravel-cross-eloquent-search", "version": "3.4.0", @@ -10747,6 +11035,86 @@ ], "time": "2022-03-08T17:03:00+00:00" }, + { + "name": "vormkracht10/filament-2fa", + "version": "v2.0.9", + "source": { + "type": "git", + "url": "https://github.com/vormkracht10/filament-2fa.git", + "reference": "5a9d426e61d55dec9b64d78111ff8ab1c67f8e97" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vormkracht10/filament-2fa/zipball/5a9d426e61d55dec9b64d78111ff8ab1c67f8e97", + "reference": "5a9d426e61d55dec9b64d78111ff8ab1c67f8e97", + "shasum": "" + }, + "require": { + "filament/filament": "^3.0", + "filament/support": "^3.2", + "laravel/fortify": "^1.24", + "php": "^8.1", + "spatie/laravel-package-tools": "^1.15.0" + }, + "require-dev": { + "laravel/pint": "^1.0", + "nunomaduro/collision": "^7.9", + "nunomaduro/larastan": "^2.0.1", + "orchestra/testbench": "^8.0", + "pestphp/pest": "^2.1", + "pestphp/pest-plugin-arch": "^2.0", + "pestphp/pest-plugin-laravel": "^2.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Vormkracht10\\TwoFactorAuth\\TwoFactorAuthServiceProvider" + ], + "aliases": { + "TwoFactorAuth": "Vormkracht10\\TwoFactorAuth\\Facades\\TwoFactorAuth" + } + } + }, + "autoload": { + "psr-4": { + "Vormkracht10\\TwoFactorAuth\\": "src/", + "Vormkracht10\\TwoFactorAuth\\Database\\Factories\\": "database/factories/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Baspa", + "email": "hello@baspa.dev", + "role": "Developer" + } + ], + "description": "This package helps you integrate Laravel Fortify with ease in your Filament apps. ", + "homepage": "https://github.com/vormkracht10/filament-2fa", + "keywords": [ + "filament-2fa", + "laravel", + "vormkracht10" + ], + "support": { + "issues": "https://github.com/vormkracht10/filament-2fa/issues", + "source": "https://github.com/vormkracht10/filament-2fa" + }, + "funding": [ + { + "url": "https://github.com/vormkracht10", + "type": "github" + } + ], + "time": "2024-11-14T08:59:40+00:00" + }, { "name": "webmozart/assert", "version": "1.11.0", diff --git a/vite.config.js b/vite.config.js index 7377fa0..eba15c5 100644 --- a/vite.config.js +++ b/vite.config.js @@ -9,6 +9,9 @@ export default defineConfig({ plugins: [ laravel({ input: 'resources/js/app.js', + content: [ + "./vendor/vormkracht10/filament-2fa/resources/**.*.blade.php", + ], ssr: 'resources/js/ssr.js', refresh: true, }),