hryvinskyi / magento2-customer-sign-in-pack
Customer sign-in methods for Magento 2: sign in with a passkey or an e-mailed code or link, and protect the password sign-in with a second step from an authenticator app or a text message, with recovery codes, the Sign-in & Security page of the customer account and the admin tab that removes a custo
Package info
github.com/hryvinskyi/magento2-customer-sign-in-pack
Type:metapackage
pkg:composer/hryvinskyi/magento2-customer-sign-in-pack
Requires
- hryvinskyi/magento2-clock: ^1.0
- hryvinskyi/magento2-customer-sign-in: 1.0.*
- hryvinskyi/magento2-customer-sign-in-admin-ui: 1.0.*
- hryvinskyi/magento2-customer-sign-in-api: 1.0.*
- hryvinskyi/magento2-customer-sign-in-checkout: 1.0.*
- hryvinskyi/magento2-customer-sign-in-email: 1.0.*
- hryvinskyi/magento2-customer-sign-in-frontend: 1.0.*
- hryvinskyi/magento2-customer-sign-in-login-as-customer: 1.0.*
- hryvinskyi/magento2-customer-sign-in-passkey: 1.0.*
- hryvinskyi/magento2-customer-sign-in-persistent: 1.0.*
- hryvinskyi/magento2-customer-sign-in-sms: 1.0.*
- hryvinskyi/magento2-customer-sign-in-totp: 1.0.*
- hryvinskyi/magento2-rate-limit: ^1.1
- hryvinskyi/magento2-sms: 1.0.*
- hryvinskyi/magento2-totp: 1.0.*
- hryvinskyi/magento2-verification-code: 1.0.*
- hryvinskyi/magento2-webauthn: 1.0.*
- magento/framework: *
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Metapackage that installs the customer sign-in suite for Luma storefronts. Customers sign in with a passkey or with a code emailed to them, without their password. A customer can also protect their password with a second step: a code from an authenticator app or a code texted to their phone, backed by recovery codes. A store can require that second step from the customers of chosen groups. Customers manage their methods on the Sign-in & Security page of My Account, and an admin removes them on the customer page.
composer require hryvinskyi/magento2-customer-sign-in-pack bin/magento setup:upgrade bin/magento setup:di:compile # production mode only bin/magento setup:static-content:deploy -f # production mode only bin/magento cache:flush
Run from the Magento root, with Magento Open Source or Adobe Commerce 2.4.x (the suite is built and tested on 2.4.9 with PHP 8.4), PHP 8.1 to 8.5, a Luma-based theme and the platform's Persistent Shopping Cart, Checkout, Login as Customer API and Login as Customer modules. Magento refuses to enable a module while one it requires is disabled, so on a store that disabled modules by hand enable the suite's modules together before setup:upgrade: bin/magento module:enable Hryvinskyi_Clock Hryvinskyi_RateLimit Hryvinskyi_VerificationCode Hryvinskyi_Sms Hryvinskyi_Totp Hryvinskyi_WebAuthn Hryvinskyi_CustomerSignInApi Hryvinskyi_CustomerSignIn Hryvinskyi_CustomerSignInFrontend Hryvinskyi_CustomerSignInAdminUi Hryvinskyi_CustomerSignInPersistent Hryvinskyi_CustomerSignInCheckout Hryvinskyi_CustomerSignInLoginAsCustomer Hryvinskyi_CustomerSignInEmail Hryvinskyi_CustomerSignInPasskey Hryvinskyi_CustomerSignInTotp Hryvinskyi_CustomerSignInSms.
How the methods work together
| Method | Package | What it does | On after install |
|---|---|---|---|
| Email code | -customer-sign-in-email |
Signs in with a 6-digit code or a one-click button emailed to the customer's address. It replaces the password: an account with a second step still finishes it. | Yes |
| Passkey | -customer-sign-in-passkey |
Signs in with a passkey (fingerprint, face or screen lock), no address typed, and with no second step. Having a passkey turns the second step on for password and email-code sign-ins, and a passkey answers that second step. | Yes |
| Authenticator app | -customer-sign-in-totp |
A second step: a code from any authenticator app (RFC 6238) after the password or the email code. | Yes |
| Text message | -customer-sign-in-sms |
A second step: a code texted to the customer's phone. | No: it needs an SMS transport first |
| Recovery codes | -customer-sign-in |
Ten codes, each used once, shown once. They come with the customer's first passkey, app or phone and go with the last one, and finish a second step without them. | Always, with a second step |
- The second step is on while the customer has a passkey, an authenticator app or a phone. After the password or an email code they land on Finish signing in and answer it with the app, a texted code, a passkey or a recovery code.
- A second step the store requires. The customer chooses whether to have a second step, unless the store requires one from their group (Require a Second Step and Customer Groups That Need a Second Step). A customer of such a group without one is sent to Sign-in & Security from My Account and the checkout page until they add one, cannot remove their last one, and gets no web API token by password. The catalog, the cart page and content pages keep working; the few catalog and cart actions that need a signed-in customer (such as the wish list, price and stock alerts and the multiple-address checkout) are held back too, as the README of
hryvinskyi/magento2-customer-sign-in-frontendlists. An administrator signed in as the customer is not held back. - A recent sign-in. Adding or removing a method and creating new recovery codes need a sign-in within the last 15 minutes. A customer who signed in earlier signs in again first.
- Emails. The customer gets an email when a method is added or removed and when a recovery code is used.
- The admin. A role with Manage customer sign-in methods removes a customer's methods on the Sign-in methods tab of the customer page, for a customer who lost their phone or device.
- A method switched off for a website loses its buttons there and refuses new enrolments. A customer who already has it as a second step is still asked for it.
What the pack installs
hryvinskyi/magento2-customer-sign-in-api, the published contracts: the sign-in method, its roles, factors, the sign-in flow and the refusal reasons.hryvinskyi/magento2-customer-sign-in, the engine: the method pool, customers' factors and recovery codes, the waiting sign-in between the two steps, the password guard, the recent sign-in, the emails, the General settings and the permissions.hryvinskyi/magento2-customer-sign-in-frontend, the Finish signing in and Sign-in & Security pages, and the places on them where the methods add their parts.hryvinskyi/magento2-customer-sign-in-admin-ui, the Sign-in methods tab on the customer page.hryvinskyi/magento2-customer-sign-in-persistent, the bridge to the platform's Persistent Shopping Cart: a sign-in that waits for its second step leaves no "Remember Me" session behind, and the customer's choice is applied once the second step is answered.hryvinskyi/magento2-customer-sign-in-checkout, the bridge to the platform's checkout: the checkout page sends a customer who owes the second step the store requires to Sign-in & Security.hryvinskyi/magento2-customer-sign-in-login-as-customer, the bridge to the platform's Login as Customer: an administrator signed in as a customer who owes a second step is not held back.- The four methods:
-customer-sign-in-email,-customer-sign-in-passkey,-customer-sign-in-totp,-customer-sign-in-sms. - The shared blocks they build on:
hryvinskyi/magento2-verification-code(one-time codes and links),hryvinskyi/magento2-totp,hryvinskyi/magento2-webauthn,hryvinskyi/magento2-sms(text messages through a chosen transport),hryvinskyi/magento2-rate-limitandhryvinskyi/magento2-clock.
Not in the pack
- An SMS transport.
hryvinskyi/magento2-smsships only Log file (development only), which reaches no phone and refuses every text outside developer mode. A store that wants the text-message method installs a transport module for its SMS provider. hryvinskyi/magento2-customer-sign-in-gdpr, the bridge tohryvinskyi/magento2-gdpr. It adds a customer's sign-in methods to a data-subject export (never a secret, a code or a key; a phone only masked), and removes them before the account is erased or anonymised. It needs PHP 8.3 or later. Install it on a store that runs that GDPR suite:composer require hryvinskyi/magento2-customer-sign-in-gdpr.hryvinskyi/magento2-customer-sign-in-privacy-consent, the bridge tohryvinskyi/magento2-privacy-consent-frontend. It keeps the privacy consents page of My Account, and withdrawing a consent there, open for a customer who owes the second step the store requires. Neither this pack nor the privacy consent pack includes it. A store that runs both suites installs it by name:composer require hryvinskyi/magento2-customer-sign-in-privacy-consent.- A store without the Persistent Shopping Cart, Checkout or Login as Customer API module cannot install the pack, because its bridges require them. The Login as Customer bridge also needs the platform's Login as Customer module enabled, which implements that API; a store that disabled it leaves out
-customer-sign-in-login-as-customer. Such a store requires the packages one by one and leaves out the bridge whose platform module it lacks (-customer-sign-in-persistent,-customer-sign-in-checkout,-customer-sign-in-login-as-customer).
Bring it into use
- Open Stores > Settings > Configuration > Customers > Sign-in Methods. Check General (second-step time limit, attempts, wrong entries per hour, recent sign-in window, the second step the store requires and its customer groups, the emails to customers) and the group of each method: Email Code, Passkeys, Authenticator App and Text Message.
- Give each admin role what it needs under System > Permissions > User Roles: Stores > Settings > Configuration > Customer Sign-in Methods for the settings, and Customers > All Customers > Manage customer sign-in methods to remove a customer's methods.
- For text messages, install and choose a transport under Stores > Settings > Configuration > General > Text Messages, then set Text Message > Enabled to Yes.
- On the storefront, open the sign-in page: it shows Email me a sign-in code and, in a browser with passkeys, Sign in with a passkey. Sign in as a customer: My Account lists Sign-in & Security.
- Read the limits below before the store relies on the suite.
Limits
- Only the password sign-in and the email code lead to the second step. A module that signs a customer in without the platform's password check, such as a social login, opens a session with no second step.
- The private RSS feeds, which sign in by HTTP authentication, answer
401for a customer with a second step. - API tokens. A REST or GraphQL customer token requested with a password is refused for a customer with a second step, and for a customer who owes the second step the store requires: no token API completes or sets up a second step. A token issued before the store required a second step works until it expires.
- The checkout page only. A customer who owes the second step the store requires is held back on the one-page checkout page. An order placed without opening that page is not stopped: an express payment button that starts a payment provider's own review flow, one-click purchase on the product page, and a web API call the storefront makes with the customer's session.
- Hyvä themes are not supported. The storefront parts are Luma templates and RequireJS widgets.
- Tested on Magento 2.4.9 only. The packages set no Magento version constraint. On 2.4.6, the record of the request's password checks is not reset between requests on an application server that keeps objects in memory; PHP-FPM is not affected.
- Email code timing. The answer to a code request takes longer for an address that has an account. The store's registration form already tells whether an address has one.
- Blocking an address's email sign-in. Anyone who knows an address can block its email sign-in for an hour with 10 wrong codes (Wrong Codes per Hour). The second step's hourly limit makes the same trade-off.
- One authenticator app per customer is enforced in the application code, not by a database constraint.
- Text messages are off by default and need a transport that is not in the pack.
- Codes after an account is deleted. Email and text-message codes, hashed and bound to the customer, stay stored for up to 24 hours, until the daily clean-up.
- "Remember Me" is applied to a sign-in with a second step as the box was left on the sign-in page, once the second step is answered.
- Translations. The wording ships in
en_USand 25 more locales: the official languages of the European Union, Norwegian Bokmål and Ukrainian. They are machine-made and no native speaker has read them.
Each package's README describes its pages, settings and limits.