Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add two-factor authentication component, including forms, pages, midd… #46

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

aminedouiri
Copy link

@aminedouiri aminedouiri commented Sep 13, 2024

Two-Factor Authentication :

  • To integrate the two factor authentication componenet you should following these steps :

Step 1 install laravel fortify and configure it :

-  Run these commands :  composer require laravel/fortify` &  php artisan fortify:install
-  Install added column by run this command  :  `php artisan migrate`
  • Setting the configuration of twoFactorAuthentication in config/fority.php :
    image

  • Add trait TwoFactorAuthenticatable in User model :
    image

Step 2: Check if Sanctum is installed in your application. If it isn't, install it :

  • Run this command php artisan install:api
  • Add a trait for sanctum tokens HasApiTokens located in use Laravel\Sanctum\HasApiTokens;
    image

Step 3 Add two factor form in edit profile page :

  • Add the shouldShowTwoFactorForm function and set it to true :
    image

  • Form for when two-factor authentication is disabled :
    image

- To enable it, click the button and enter your password :

image

  • Form for when two-factor authentication is enabled :
    image

  • For disabled it click on the button and insert your password
    image

Step 4 add two factor page :

-  Add middlewares in bootstrap\app.php : 

image

  • Add /admin/two-factor route:
```
  use Joaopaulolndev\FilamentEditProfile\Pages\TwoFactorPage;

  Route::get('admin/two-factor', TwoFactorPage::class)
    ->name('two_factor_page')
    ->middleware(['filament-auth', 'twoFactorFilament']);
  • Update the login form in the admin panel provided by the login of the profile edit plugin :
    image

  • Add two-factor authentication middleware in the authMiddleware of Filament :
    image

  • Two-factor authentication page for approval using a code or recovery codes :
    image

…lewares, and translations for all supported languages
@Abdelhalim-Merabet
Copy link

for disabling the Two Factor, I think its a good practice to ask for the current code and the password

@RibesAlexandre
Copy link

Hi,

Any news about this pull request ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants