Download the PHP package nakipelo/orchid-2fa-totp without Composer

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

Orchid 2FA — TOTP

An authenticator-app channel (TOTP: Google Authenticator, Microsoft Authenticator, 1Password, Aegis and other RFC 6238 apps) for nakipelo/orchid-2fa, the two-factor authentication of the Laravel Orchid admin panel.

nakipelo/orchid-2fa does the sign-in flow, the attempt limits, trusted devices, recovery codes, the profile screen and the admin reset; this package adds the method "Authenticator app" (channel totp):

Requirements

Installation

The service provider is auto-discovered and registers the channel totp (TwoFactor::extend('totp', …)).

Optionally publish what you want to change:

The migration is loaded from the package; publish it only to change it (for example, a non-bigint users.id), and do it before php artisan migrate: the copy keeps the file name and replaces the package migration.

Enabling the method

The channel is offered when totp is in channels.allowed of config/orchid-2fa.php. The default there is ['email', 'totp'], so after the installation users can choose between e-mail and an authenticator app; nothing else to configure.

Only the authenticator app: allow only totp:

A user who needs 2FA and has no app sets it up at the next sign-in, right after the password. Users whose current method is e-mail are moved to the app at their next sign-in (a code by e-mail as a proof, then the setup) — see Moving all users to another method for who is asked for what, how to count the users who will set it up with the password only, and the rollback.

Setting up the app

Both places are screens of nakipelo/orchid-2fa; this package supplies the setup step:

The setup step shows a QR code, the key in groups of four characters with the account ("Issuer (label)") and an otpauth:// link for an app on the same device. The partial has no inline styles or scripts, so it works under a strict Content-Security-Policy (the QR code is an inline SVG sized by its width/height attributes). A new 160-bit secret is kept only in the server session until the first correct code; then it is stored. Setting up again replaces the secret only after the code of the new one, so the old app works until then.

At sign-in the code screen asks for "the code from your authenticator app"; the attempt limits are those of verifier channels in nakipelo/orchid-2fa (Limits).

Recovery codes

The method needs recovery codes (a lost phone), so nakipelo/orchid-2fa issues them whenever the app is set up, and accepts them at sign-in ("Use a recovery code") and in the profile. They are a feature of the main package: see Recovery codes.

Configuration

config/orchid-2fa-totp.php (keys orchid-2fa-totp.*):

Key Default Meaning
window 1 Tolerance in 30-second steps before and after the current one (clock drift, typing time). 0 — only the current step; a negative number counts as 0, a value that is not a number as 1. The algorithm itself (SHA1, 6 digits, 30 s) is fixed: it is what the apps use.
email_fallback false Offer "Send a code by e-mail instead" on the code screen (E-mail fallback).
issuer null Name the app shows above the code; null — config('app.name').
label null Account name in the app; null — the user's e-mail address (the attribute orchid-2fa.channels.email.attribute, email by default).

The settings of 2FA itself (allowed methods, attempt limits, recovery codes, enrollment_ttl) are in config/orchid-2fa.php of nakipelo/orchid-2fa.

Issuer and label per user

A string in the config is the same for everyone. To compute the issuer or the label per user, register closures in a service provider of the application (a closure in a config file breaks config:cache):

A closure takes precedence over the config; an empty result falls back to app.name / the e-mail address. null removes the closure. The values are written into the app at the setup: changing them later does not change apps already set up.

E-mail fallback

With email_fallback = true the code screen of a TOTP user offers "Send a code by e-mail instead" — a regular e-mail code under the e-mail send limits of nakipelo/orchid-2fa — but only while:

The hash is written only at the setup and at "Set up again", never at sign-in. After a change of the address — for example from a stolen session — the fallback is unavailable until the owner sets up the app again, which also stores the new address. nakipelo/orchid-2fa checks the condition again when the fallback is requested.

Replay protection

A code is accepted only for a time step after the last accepted one (two_factor_totp.last_step), so a code cannot be used twice, nor an older code after a newer one, including the code of the setup. The step is taken with an atomic conditional UPDATE … WHERE secret = ? AND (last_step IS NULL OR last_step < ?): of parallel requests with the same code only one passes, and a code of the old secret checked while "Set up again" completes is refused (the row then holds the new secret).

The consequences:

Removing the package

In this order:

  1. Reset the users of the method, otherwise they cannot sign in (fail-closed):

    (The command of nakipelo/orchid-2fa also works after the removal.)

  2. If config/orchid-2fa.php lists totp in channels.allowed, remove it and keep another method there — after "only the authenticator app" (['totp']) put back ['email']. A name without a driver is ignored, and with no allowed method left nakipelo/orchid-2fa throws on boot in local/testing (so composer remove fails in its package:discover step); elsewhere users who need 2FA cannot sign in.
  3. Roll back the migration while the package is still installed — only the migrations of this path are rolled back (the others are listed as "Migration not found"):

    For a published migration pass the path of the copy.

  4. composer remove nakipelo/orchid-2fa-totp.

If the package is already removed, drop the table two_factor_totp and delete its row from the migrations table by hand. The users reset in step 1 sign in with the default method (e-mail codes, when email is allowed) or set up an allowed one at the next sign-in.

Limitations

Development

The tests run on SQLite in memory. tests/Feature/ReplayTest.php, ResetTest.php and VerificationTest.php also run on MySQL and PostgreSQL in CI (job databases): set DB_CONNECTION (mysql or pgsql) and the DB_* variables of a test database to run them locally, for example

On a server the test with parallel processes uses a second connection to that database (on SQLite a shared file); it needs pcntl and posix and is skipped without them. The conformance suite below boots its own SQLite database.

Conformance suite

tests/Conformance/TotpChannelConformanceTest.php runs the conformance suite of nakipelo/orchid-2fa 0.2 (ChannelConformanceTestCase) against the channel, including:

invalidCode() returns a code that is none of the codes (±3 steps) of the current secret and of the secret of the enrollment step the code is for (the $state argument of the suite), so the wrong code of an enrollment is never a valid one by chance.

The workbench allows ['email', 'totp']; ORCHID_2FA_ALLOWED=totp and ORCHID_2FA_TOTP_FALLBACK=1 in the environment of composer serve switch to TOTP only and enable the e-mail fallback. The test administrator holds all permissions, so it is enforced: by default it gets an e-mail code (in the log); with ORCHID_2FA_ALLOWED=totp it sets up the app right after the password.

License

MIT, see LICENSE.


All versions of orchid-2fa-totp with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
bacon/bacon-qr-code Version ^3.0
laravel/framework Version ^11.35 || ^12.0 || ^13.0
nakipelo/orchid-2fa Version ^0.2
orchid/platform Version ^14.53
pragmarx/google2fa Version ^8.0 || ^9.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 nakipelo/orchid-2fa-totp contains the following files

Loading the files please wait ...