Download the PHP package inlayphp/two-factor-authentication without Composer

On this page you can find all versions of the php package inlayphp/two-factor-authentication. 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 two-factor-authentication

Inlay two-factor authentication

inlayphp/two-factor-authentication is an optional, Laravel-first security plugin for Inlay panels. It adds encrypted TOTP credentials, one-use recovery codes, enrollment confirmation, and a composable login challenge step without making inlayphp/panels depend on a particular authentication or permission product.

The package is intentionally separate from the panel core. Install it only in applications that need two-factor authentication; profile and password screens can remain part of the application or another account plugin.

Requirements

The current package is framework-neutral at the manager boundary and does not require Fortify. Existing Fortify applications can opt into the storage adapter documented below without changing the TOTP or panel contracts.

Install

The service provider is discovered by Laravel. The migration adds the following nullable columns to the configured users table:

Set INLAY_TWO_FACTOR_ISSUER to control the issuer shown by authenticator applications. Column/table names, code period, clock window, and recovery-code count are configurable in config/inlay-two-factor.php.

User model

Add the contract and trait to the same model used by the panel guard:

HasTwoFactorAuthentication stores encrypted state through the package manager. Do not expose the encrypted secret or recovery-code attributes in API resources or ordinary user serialization.

Existing Laravel Fortify users

If the model already uses Fortify's Laravel\Fortify\TwoFactorAuthenticatable trait, use Inlay's compatibility trait instead of HasTwoFactorAuthentication:

The adapter preserves Fortify's two_factor_* columns and translates its single encrypted recovery-code JSON document at the model boundary. The Inlay manager can therefore provide the same Forms, panel settings, QR adapter, and row-locked one-use challenge flow without adding Fortify to this package's Composer requirements. Use the same Laravel encryption binding for Fortify and the Inlay manager; if Fortify has been configured with a custom encrypter, configure the manager to use that binding as well. Do not combine this trait with HasTwoFactorAuthentication, or run both packages' storage migrations for the same model.

Enrollment and security settings

Resolve TwoFactorManager from Laravel's container in an authenticated, current-password-confirmed controller or action. The plugin also ships a panel settings page for the same flow (see the panel section below):

Render the URI as a QR code in the application and ask the user to enter a current authenticator code before calling:

Only return the plaintext secret and recovery codes during the initial, authenticated enrollment response. Treat that response as sensitive data.

When TwoFactorAuthenticationPlugin is registered, GET /{panel}/settings/two-factor renders inlay-two-factor/settings. The page uses the shared Inlay Form contract for setup, confirmation, recovery-code regeneration, and disable actions. State-changing security actions require the current password and are throttled. The enrollment payload contains secret, otpauthUri, and recoveryCodes. Inlay deliberately does not bundle a QR dependency: pass otpauthUri to the QR component your application already uses or provide a QR adapter at the application edge. To let the official page render the QR image, bind the optional contract in an application service provider:

MyQrRenderer::render() receives the otpauth:// URI and must return an image src value, such as a data URI or an application-served URL. If no binding is present, the page still displays the setup URI for a manually supplied QR component.

The supplied React and Vue settings pages inherit the Panel's semantic theme contract. Success, warning, and danger feedback use the shared status surface tokens, while the setup and confirmation forms are the standard Inlay Form renderer. A custom panel theme therefore updates both security settings and the rest of the admin UI in light and dark mode. The QR image intentionally keeps a light surface for scanner reliability; its surrounding card remains themeable.

Panel login challenge

Panels exposes an ordered post-credential LoginStep pipeline. Register the optional step in the panel provider:

The plugin registers the public challenge GET/POST routes and the login step records a short-lived pending marker when an enabled user signs in, logs out the panel guard, and redirects to the panel's configured two-factor-challenge path. The application must provide the matching page component (inlay-two-factor/challenge by default) in its React or Vue resolver. The package controller resolves the pending panel and user, calls TwoFactorManager::verifyChallenge(), clears the marker after success, regenerates the session, and redirects to the safe intended URL. Never put the user ID, secret, recovery code, or pending marker in a URL.

Keeping Fortify as the login owner

If the application authenticates through Fortify instead of the Inlay Panel login pipeline, register the opt-in bridge from the application's Fortify service provider:

The bridge binds Fortify's TwoFactorChallengeViewResponse to an Inertia response using the same React/Vue page and Inlay Form contract. Fortify keeps ownership of token verification, recovery-code consumption, throttling, session rotation, and redirects. It is intentionally opt-in and throws a clear installation error if Fortify is not installed. Do not register this bridge together with the Inlay Panel TwoFactorLoginStep for the same login flow.

For a Fortify application that does not use an Inlay Panel, register the standalone settings routes as well:

This registers authenticated GET/POST routes for enrollment, confirmation, recovery-code regeneration, and disablement. It uses the same settings page, password confirmation, QR adapter, and row-locked manager as the Panel flow. The bridge is opt-in and adds auth plus the configured Fortify web middleware; applications should not register it twice.

Recovery codes are normalized and consumed once. disable() clears the secret, confirmation timestamp, and remaining recovery codes; protect enrollment, disable, and recovery-code regeneration with current-password confirmation, authorization policies, CSRF protection, and rate limits in the application.

Configuration

Key Default Purpose
issuer APP_NAME / Inlay Authenticator-app issuer
digits 6 TOTP code length (6–8)
period 30 TOTP period in seconds
window 1 Accepted clock-skew windows
recovery_codes 8 Codes generated at enrollment
pending_session inlay.two-factor.pending Pending challenge session key
challenge_path two-factor-challenge Relative panel challenge path
table users User table for the migration

Security boundaries

The plugin supplies cryptographic primitives and the panel hand-off; it does not guess application policy. Applications remain responsible for:

Tests

The package tests include the RFC TOTP vector, encrypted enrollment payloads, confirmation, single-use recovery codes, recovery-code rotation, disable behavior, migration idempotence, and panel login suspension. The shared Inlay forms and React/Vue challenge and settings renderers are covered by their package test suites.

Related packages


All versions of two-factor-authentication with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/auth Version ^12.0 || ^13.0
illuminate/container Version ^12.0 || ^13.0
illuminate/database Version ^12.0 || ^13.0
illuminate/http Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0
inertiajs/inertia-laravel Version ^3.0
inlayphp/forms Version ^0.3 || dev-main
inlayphp/panels Version ^0.3 || dev-main
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 inlayphp/two-factor-authentication contains the following files

Loading the files please wait ...