Download the PHP package triopsi/simple-two-factor without Composer

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

Licensed under the MIT License Requires PHP 8.2.0 Last Commit codecov

SimpleTwoFactor Plugin for CakePHP 4

This plugin provides a simple two-factor authentication (2FA) mechanism for CakePHP 4 applications. It uses the RobThree/TwoFactorAuth library to handle the generation and verification of 2FA codes.

Features

Requirements

Two-Factor Authentication (2FA) Workflow

Two-Factor Authentication adds an additional layer of security to the authentication process by requiring not only a username and password but also a unique code generated by an authentication app.

Workflow Overview

  1. User Registration with 2FA Setup

    • After registering or editing their profile, the user is presented with a QR code.
    • The QR code contains a secret key.
    • The user scans the QR code using an authentication app (e.g., Google Authenticator, Authy).
    • This generates a secret pair shared between the server and the user’s device.
  2. Subsequent Logins

    • After entering the correct username and password, the user is prompted for a Two-Factor Authentication (2FA) code.
    • The user opens the authentication app to retrieve the current TOTP (Time-based One-Time Password).
    • The TOTP code is submitted to the server.
  3. Verification and Access
    • The server verifies the TOTP code using the shared secret.
    • If the code is correct and matches the expected value, the user is granted access to the application.
    • If the code is incorrect, access is denied.

Technical Details

This process ensures that even if a user's primary credentials are compromised, unauthorized access is prevented without the second factor of authentication.

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

Configuration

1. User Secret Store

To save the secret and to assign the user. The plugin requires a secret field in the user table. This could look as follows:

or via migration:

2. Load the Plugin

Load the plugin in your Application.php file:

Alternatively, execute the following line:

3. Add Middleware

Add the TwoFactorMiddleware to your middleware queue in src/Application.php. Make sure to add it directly under the AuthenticationMiddleware.

Middleware Options

The TwoFactorMiddleware class provides several configuration options that can be customized to fit your application's needs. Below are the available options along with their explanations:

Example Configuration in Application.php

To configure the TwoFactorMiddleware in your CakePHP application, you need to set the options in the middleware method of your Application.php file.

! It is important that the TwoFactorMiddleware is placed after the AuthenticationMiddleware. If the order is incorrect, the plugin cannot work properly.

4. Example Controller Action

Create a method in your UsersController to handle the 2FA verification.

Example for UsersController.php

5. Example View

Create a view for the 2FA verification form.

Example for verifytfa.php

SimpleTwoFactorComponent for CakePHP 4

The SimpleTwoFactorComponent provides methods to handle Two-Factor Authentication (2FA) in your CakePHP 4 application. This component allows you to generate secrets, verify codes, and create QR codes for easy setup with 2FA apps.

Features

Load the Component

Load the SimpleTwoFactorComponent in your controller:

Generating a QR Code

To generate a QR code for the user to scan with their 2FA app, you need to create a secret and then generate the QR code image.

Example View

Create a view for the 2FA setup form where the user can scan the QR code.

Example for setup2fa.php

Bugs & Feedback

https://github.com/triopsi/SimpleTwoFactor/issues

License

Copyright (c) 2025, Triopsi and licensed under The MIT License.


All versions of simple-two-factor with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
cakephp/cakephp Version 4.5.8
robthree/twofactorauth Version ^3.0
bacon/bacon-qr-code Version ^2.0
cakephp/migrations Version @stable
cakephp/authentication Version ^2.11
endroid/qr-code Version ^5.0
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 triopsi/simple-two-factor contains the following files

Loading the files please wait ....