Download the PHP package calmfox/neos-two-factor-package without Composer

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

Neos Two-Factor Package

Build

English | Polski

Two-factor authentication for the Neos CMS backend. Each user chooses their second factor: a passkey (fingerprint, face or device PIN) or an authenticator app (TOTP).

Features

Requirements

Version
Neos 8.3, 8.4, 9.x
PHP 8.2, 8.3, 8.4, with sodium and openssl
Database MySQL / MariaDB or PostgreSQL
Browser for passkeys any current browser, over https (plain http works on localhost only)

Tested on Neos 8.3.35 (Flow 8.3.20, PHP 8.2), Neos 8.4.8 (Flow 8.4.5, PHP 8.2) and Neos 9.1.10 (Flow 9.1.3, PHP 8.3), all on MariaDB.

This package replaces other second-factor packages for the backend, such as sandstorm/neostwofactorauthentication. Running two would ask users for two second factors; pick one.

Installation

The migration adds two tables: calmfox_twofactor, one row per backend account that has paired something, and calmfox_twofactor_policy, which holds the policy once somebody chooses one in the backend. Deleting a user in Neos deletes their row.

Nothing has to be added to the project's Routes.yaml: the package answers its few addresses (/neos/two-factor/...) itself, right after Flow's router, so they work whether the project keeps its own Configuration/Routes.yaml or not.

Before you deploy to a live site, decide on the policy. The default is required, so at their next sign-in every user, including you, is sent to the setup page. That works, but may be a surprise. To introduce it gradually, start with:

Users then pair from User → Two-Factor Authentication, ./flow twofactor:list shows who has, and once everyone is ready, ./flow twofactor:policy --policy required makes it mandatory.

Configuration

Who has to use a second factor is chosen in the backend. The rest is in Settings.yaml:

How it works

The guard is a middleware placed right after Flow's security entry point, not a hook on the sign-in itself, because the question is not "did you just sign in" but "may this request go on". A session that never answered its challenge is stopped on every request, including one opened from a bookmark hours later, and including the frontend, where a backend session would otherwise show unpublished content. Its own pages and Neos' sign-in and sign-out are always allowed, so nobody who cannot answer is trapped. A request from a script (the content editor fetching JSON) gets a plain 403 instead of a redirect, and the next page the person loads takes them where they need to go.

What counts as answered is kept in the Flow session and records which account answered, so it cannot be inherited by whoever signs in next on the same browser. A fresh password wipes it, signing out destroys it, and answering gives the session a new id.

One-time passwords are RFC 6238 over RFC 4226 with the parameters every authenticator app uses: SHA-1, a 30-second step, six digits. They are implemented in this package rather than pulled in as a dependency: it is forty lines of arithmetic, and the RFC's own test vectors are in the test suite.

A code is spent once. A code is right for as long as its thirty-second step lasts, and a step either side of now is accepted for clocks that drift, so the same six digits would otherwise answer twice: read off a screen share, seen over a shoulder, or replayed from a captured request. The newest step an account has used is recorded, and anything from that step or earlier is refused. The code typed to pair the app counts as spent too. The record is claimed with a single conditional UPDATE rather than a read and then a write, because two requests arriving together with the same code would both pass the latter.

Passkeys are the one second factor phishing cannot relay: the signature covers the address of the site, so a look-alike page never gets a valid one. The library accepts any host that merely ends with the configured domain, so the package checks the origin itself: the exact site or a real subdomain, over https, with plain http allowed only on localhost as browsers do.

Setting up leaves nothing half-done. The authenticator secret waits in the session and only reaches the account once a code it produced has been typed; a passkey is stored only once its signature verifies.

The secret at rest. Flow has no encryptor for values that have to be read back, and a TOTP secret has to be. It is sealed with libsodium's secretbox under a key derived (HKDF) from the installation's Flow encryption key, so a dump of the table is not enough to produce codes. The flip side: a new Flow encryption key makes stored secrets unreadable. Those users are then treated as having no app and asked to pair again; passkeys are not affected.

Recovering an account

If a user loses their phone, an administrator resets them on the user's page in Administration → User Management, or in the overview under Administration → Two-Factor Authentication. If nobody can sign in at all:

They keep their password and pair a new device at the next sign-in. --disable removes what is paired without demanding a new pairing, and the policy then decides. --provider selects an account of another authentication provider.

Appearance

What this does not cover

Development

The unit tests cover the framework-free core (the one-time passwords against the RFC's own test vectors, the base32 they travel in, the policy decisions, the passkey bookkeeping, the sealed secret and the page addresses) plus the wiring that only meets inside Neos: every translation id in both languages, a privilege for every controller action, the modules in the settings. They need neither Neos nor a database:

Any PHPUnit 10 or newer works; the package needs no composer install of its own.

Security

See SECURITY.md for how to report a vulnerability.

License

MIT


All versions of neos-two-factor-package with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-json Version *
ext-openssl Version *
ext-sodium Version *
bacon/bacon-qr-code Version ^3.0
lbuchs/webauthn Version ^2.2
neos/flow Version ^8.3 || ^9.0
neos/neos Version ^8.3 || ^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 calmfox/neos-two-factor-package contains the following files

Loading the files please wait ...