Download the PHP package mustafa-awami/lara2fa without Composer

On this page you can find all versions of the php package mustafa-awami/lara2fa. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package lara2fa

Build Status Linter Status Latest Stable Version Total Downloads License Laravel 12+

Lara2FA is a modern, flexible, and developer-friendly Two-Factor Authentication (2FA) package for Laravel. It supports powerful authentication methods out of the box:

Designed for simplicity, security, and seamless integration into any Laravel project.


πŸ“œ Table of Contents


πŸš€ Features


πŸ“ Prerequisites


🧰 Installation

Install via Composer:


βš™οΈ Set Up

Step 1️⃣: Install & Publish

After installing via composer, publish resources using the lara2fa:install Artisan command

During installation, you’ll be asked which starter kit/stack you are currently using:

Then you will be asked which of the following 2FA methods would you like to enable:

Depending on the selected methods, the published lara2fa.php config file will be updated to enable the selected methods and disable the rest.

⚠️ Warning

This instalation process may override some of your files in your project directory, see the full list of files at the Troubleshooting Section

Step 2️⃣: User Model

In User.php model, replace:

with:

Step 3️⃣: Routes

In settings.php route file, replace:

with:

Step 4️⃣: Fortify Config

In fortify.php config file, disable the two-factor feature by commenting it out like so:

Step 5️⃣: Migrate & Build

Run the migrations to create the new tables:

Finally, run the build command:


πŸ§ͺ Example Repository

You will find an example of usage on Mustafa-Awami/lara2fa-example.


πŸ’» Usage

Users can enable any of the two-factor methods in thier settings page.

By enabling any of the main 3 methods, recovery codes will be enabled automaticly.

Users who have enabled any of the two-factor methods will be automatically redirected to the two-factor-challenge page after entering their password.

If a user enabled passkeys, they can login directly without entering their password in the login page by clicking on the Use Passkey button (passwordless authentication).


πŸ› οΈ Configuration (Optional)

Two-Factor Authentication

1- Authenticator App (TOTP)

This section configures Two-Factor Authentication (2FA) using a time-based one-time password (TOTP) app like Google Authenticator or Authy.

You will find the configuration for this feature in lara2fa.php config file under Features:authenticatorAppTwoFactorAuthentication([...]).

2- Email (OTP)

This configures 2FA by sending a one-time code to the user's registered email address.

You will find the configuration for this feature in lara2fa.php config file under Features:emailTwoFactorAuthentication([...]).

3- Passkeys

This configures login using device-based security like Face ID, Touch ID, Windows Hello, or physical security keys (YubiKey). It can also be used as passwordless authentication.

You will find the configuration for this feature in lara2fa.php config file under Features:passkeys([...]).

4- Recovery Codes

This configures one-time-use backup codes for users who lose access to their 2FA device.

You will find the configuration for this feature in lara2fa.php config file under Features:recoveryCodes([...]).

Routes

If you want to customize the lara2fa.php route file, first publish it with the following command:

Then, in routes/web.php, add the following line at the end:

Make sure to disable the original route file by adding Lara2fa::ignoreRoutes(); in the register method of app/Providers/Lara2faServiceProvider.php:

Here is the list of defined routes:

Request Route Name Description
GET /two-factor-challenge two-factor.login Show the two-factor authentication challenge view.
POST /two-factor-challenge - Submitting the two-factor authentication challenge form.
POST /settings/authenticator-app-two-factor-authentication authenticator-app-two-factor.enable Enable authenticator-app two-factor authentication for the authenticated user.
POST /settings/confirmed-authenticator-app-two-factor-authentication authenticator-app-two-factor.confirm Confirm authenticator-app two-factor authentication for the authenticated user.
DELETE /settings/authenticator-app-two-factor-authentication authenticator-app-two-factor.disable Disable authenticator-app two-factor authentication for the authenticated user.
GET /settings/authenticator-app-two-factor-qr-code authenticator-app-two-factor.qr-code Get the SVG element for the user's two-factor authentication QR code.
GET /settings/authenticator-app-two-factor-secret-key authenticator-app-two-factor.secret-key Get the current user's two-factor authentication setup / secret key.
POST /settings/email-two-factor-authentication email-two-factor.enable Enable email two-factor authentication for the authenticated user.
POST /settings/confirmed-email-two-factor-authentication email-two-factor.confirm Confirm email two-factor authentication for the authenticated user.
DELETE /settings/email-two-factor-authentication email-two-factor.disable Disable email two-factor authentication for the authenticated user.
POST /settings/email-two-factor-authentication-send-code email-two-factor.send-code Send the OTP via email.
GET /settings/passkeys-two-factor-authentication passkeys-two-factor.get Get the user's passkeys.
GET /settings/passkeys-two-factor-authentication-registerOptions passkeys-two-factor.getRegisterOptions Get passkey registration options.
POST /settings/passkeys-two-factor-authentication passkeys-two-factor.store Create a new passkey for the authenticated user.
DELETE /settings/passkeys-two-factor-authentication passkeys-two-factor.disable Delete all passkeys for the authenticated user.
DELETE /settings/passkeys-two-factor-authentication/{passkey}/destroy passkeys-two-factor.destroy Delete the provided passkey for the authenticated user.
PUT /settings/passkeys-two-factor-authentication/{passkey}/update passkeys-two-factor.update Update the name of the provided passkey for the authenticated user.
GET /settings/two-factor-recovery-codes two-factor-recovery-codes.get Get the two-factor authentication recovery codes for the authenticated user.
POST /settings/two-factor-recovery-codes two-factor-recovery-codes.generate Generate a fresh set of two-factor authentication recovery codes.
DELETE /settings/two-factor-recovery-codes two-factor-recovery-codes.disable Delete the two-factor authentication recovery codes for the authenticated user.
GET /passkeys-two-factor/authenticateOptions passkeys-two-factor.authenticateOptions Get passkey authentication options.
POST /passkeys-two-factor/authenticate passkeys-two-factor.authenticate Authenticate the user with the given passkey.

You can customize the first part of the URL by setting the prefix value in the lara2fa.php config file.

Rate Limiter

Lara2fa defines 3 rate limiters:

1- Passkey Login Attempts (passkey-login)

2- Two-Factor Email Notification (two-factor-email-notify)

3- Two-Factor Code Verification (two-factor-login)

You can find and customize the rate limiters inside the boot method of \app\Providers\Lara2faServiceProvider.php.

You can also view them inside the limiters value in the lara2fa.php config file.


πŸš‘ Troubleshooting & Important Notes

⚠️ Warning: File Overwrites

The installation process may publish files that overwrite existing files in your project (for example, configuration or resource files). It’s strongly recommended to commit your changes or back up your project before running the install command.

Here is the list of files that will be published:

Here are the React resource files that will be published if React is chosen:

Here are the Vue stack files that will be published if Vue is chosen:

Passkey Requirements

For Passkeys to work correctly, the following conditions must be met:


πŸ‘₯ Contributing

Thank you for considering contributing to Lara2fa! You can read the contribution guide.


πŸ”’ Security Vulnerabilities

Please review the security policy on how to report security vulnerabilities.


βš–οΈ License

The Lara2FA package is licensed under the MIT license.


πŸ’– Support

If you find this package helpful, please consider sponsoring the project to support its development and maintenance!

Sponsor


All versions of lara2fa with dependencies

PHP Build Version
Package Version
Requires web-auth/webauthn-lib Version 5.2
php Version ^8.2
laravel/fortify Version ^1.32
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mustafa-awami/lara2fa contains the following files

Loading the files please wait ...