Download the PHP package chillerlan/2fa-qrcode-bundle without Composer

On this page you can find all versions of the php package chillerlan/2fa-qrcode-bundle. 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 2fa-qrcode-bundle

chillerlan/2fa-qrcode-bundle

An authenticator (chillerlan/php-authenticator) and a QR Code generator (chillerlan/php-qrcode) bundled together for MFA in frameworks and applications.

PHP Version Support Packagist version License Continuous Integration Packagist downloads

Requirements

Documentation

You can find the documentation of the bundled libraries in their respective repositories:

User Guide

Invocation

Fetch the settings from e.g. a framework config and invoke the TwoFactorQRCodeOptions instance with it. Please note that this object combines the settings for AuthenticatorOptions and QROptions. Alternatively, you can just pass an iterable of options to the TwoFactorQRCode constructor.

User registration

Normal usage: log-ins, reverification etc.

Using a backup code

The user has lost access to their authenticator, send them to a form separate from the usual OTP input:

Redirect the user to wherever they can manage their 2FA settings and retrieve their secret once again:

Validating an e-mail address

The previous flow can also be used for other tasks, such as e-mail verification:

Now present the user with a form where they can enter the received code:

A note on the secret length

The secret length as per the specifications (RFCs 4226 and 6238) is the length of the binary string that is given to the HMAC hash function - there is no encoding involved at all. Google's "Key URI format" specification uses base32 encoding in order to make the binary secret string portable (URI safe). The base32 encoding naturally results in longer strings than the original, about 60%, so a secret of 20 bytes length results in a 32 byte long base32 encoded string.

However, some of the top used libraries on packagist use some kind of pseudo base32 encoding, with a shorter secret string than requested as a result (secret length = base32 encoded length), which can compromise the security of the algorithm.

This library refers to the secret length always as the length of the raw binary string.

API

TwoFactorQRCode

The class is not final and you're free to extend it to add/change functionality to your liking.

method return description
__construct(SettingsContainerInterface\|TwoFactorQRCodeOptions \|iterable $options = new TwoFactorQRCodeOptions) -
createSecret(int\|null $length = null) string Creates a cryptograpically secure random secret and returns it as Base32 encoded string
setSecret(string $encodedSecret) static Sets a secret phrase from an encoded representation
getSecret() string Returns an encoded representation of the current secret phrase
setRawSecret(string $rawSecret) static Sets a secret phrase from a raw binary representation
getRawSecret() string Returns the raw representation of the current secret phrase
verifyOTP(string $otp, int\|null $timestamp = null) bool Verifies a one-time password (TOTP) with an optional unix timestamp
createBackupCode(int $counter) string Creates a counter-based one-time password (HOTP) from the given counter value
verifyBackupCode(string $otp, int $counter) bool Verifies a counter-based backup code (HOTP) against the given counter value
getQRCode(string $label, string $issuer) string Creates a QR Code for use with a mobile authenticator application (TOTP) with the given label and issuer name

Anti clanker policy

No fascist plagiarism machines were - or will ever be - used in creating of this and any of the bundled libraries. Clanker created pull requests will not be accepted. However, I have no control over 3rd-party libraries, but will avoid clankers wherever I can.

Disclaimer

Use at your own risk!


All versions of 2fa-qrcode-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
chillerlan/php-authenticator Version ^5.4.1
chillerlan/php-qrcode Version ^6.0
chillerlan/php-settings-container Version ^3.2.1
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 chillerlan/2fa-qrcode-bundle contains the following files

Loading the files please wait ...