Home Blog WordPress Security WooCommerce and two-factor authentication

woocommerce and 2fa

WooCommerce and two-factor authentication

WordPress eCommerce security can take many forms. 2FA, short for two-factor authentication, however, is a low-hanging fruit that offers serious bang for your buck. Industry giants such as Google and Microsoft can’t sing its praises enough.

Adding 2FA to WooCommerce is much easier than you might think. WP 2FA, our very own plugin, makes it an even better proposition thanks to extensive white labeling options, multiple 2FA methods, WooCommerce integration, and custom login pages support – all available straight out of the box.

In this article, we will look at everything you need to know to add 2FA to your WooCommerce store. We will also explore why 2FA is a must for your store, what options are available, and how to get the most out of it.
Without further ado, let’s get to it.

Why do I need 2FA?

Username and password combinations have long been the authentication factor of choice in login security. It represents something we know. The premise is that we will not be allowed in if we don’t know it (the username and password combination). While in theory this works, in practice, there are issues that might make the username and password combinations less safe than we thought.

Advances in computing power have made cracking passwords easier than ever before. Compounding issues is the fact that many users tend to choose insecure passwords. Password theft has also become more commonplace, making the call for a safer login mechanism more critical than ever before. This is where 2FA comes in.

2FA combines something you know (username and password combination) with a secondary factor. The latter acts as an additional layer of security protecting your WooCommerce and WordPress login. While there are several options, something you have (such as your smartphone) and something you are (such as your fingerprint) are two of the most common secondary factors.

With 2FA, even if someone with bad intentions learns what you know (your username and password), they still need access to the second factor, such as what you have, to log in to your account. This makes a security breach far less likely.

More WooCommerce 2FA benefits

While WordPress website security is undoubtedly a huge benefit, 2FA is a gift that keeps on giving, enabling you to do more with the tools you already have.

Customer trust

Customers are becoming increasingly wary of lax website security, where they know their personal and financial information will be stored. With identity theft on the rise, this is more than justified. According to Experian, the FTC reported losses of over $6.1 billion in 2021, an increase of 77% over the previous year.

With many big-name companies using 2FA, adding the technology to your WooCommerce store will instill more confidence in your customers. You can also take advantage of lower entry barriers, thanks to familiarity with how it works.

Team flexibility

Being able to work from anywhere is a necessity in the post-2020 world. The pandemic showed us that working remotely is not only possible but has many benefits. Working remotely can achieve a better work-life balance. It also ensures that emergencies are handled faster.

One concern that often accompanies remote work is security. Administrators often find themselves having no control over the security of devices and networks used. By employing 2FA, you ensure that strong security practices are adhered to. In turn, this increases the overall security of the WordPress website.

Strong WordPress passwords remain essential, even when using 2FA. A strong door with a strong lock beats a strong door with a weak lock any time of the day.

Compliance

Standards and regulations, such as PCI DSS and GDPR, require systems owners and administrators to take reasonable security measures to keep customer data secure. Two-factor authentication is required by both, making WooCommerce 2FA a no-brainer if you’re looking to grow your online business.

WooCommerce 2FA methods

Thanks to the tight integration of WordPress and WooCommerce, 2FA methods available on WordPress will, by and large, also be available on WooCommerce. As such, you get an excellent selection of different methods, helping you ensure you can accommodate all kinds of customers and users.

WP 2FA is a plugin solution that offers many authentication methods, accommodating people from all walks of life. Set up is also very easy, ensuring your 2FA implementation has low barriers to entry and less resistance.

Authenticator app (TOTP)

Using Authenticator apps with WordPress is easy, thanks to features such as the inclusion of a QR code. With most people already having an authenticator plugin such as Google Authenticator, all they need to do is scan the code using their smartphone. Once set up, all users need to do is get the OTP (One-Time Password) from the app and log in. The code changes every 30 seconds, ensuring only those with access to the user’s phone can log in to that user’s account.

Email HOTP

Email HOTP uses a one-time code that is counter-based rather than time-based. This means that a new authentication code is generated with every validation. Instead of using an authenticator app, users receive the code via email, which can be sent to the email address of the WooCommerce account or any other email – depending on how the policy is set up.

Email links work similarly to email HOTP; however, the email contains a link instead of a code. When the link is clicked, it confirms the user confirms their identity, and access is granted. Just like Email HOTP, the policy dictates whether the user receives the email to the address associated with their WooCommerce account or whether they can choose their own.

SMS

SMS OTPs are One-Time Passwords sent via SMS. These usually work through a third-party service such as Twilio, which offers an SMS gateway. Network charges apply when using this method. The user will need to provide their phone number when configuring 2FA to ensure the SMS is sent to the right person.

Push notifications

Push notifications are notifications sent to an app like Authy. All the user needs to do is confirm that it is them who is trying to log in, and access will be granted. Of course, this requires Authy integration, which WP 2FA offers out of the box.

Backup codes

Backup codes, as the name implies, are used as a backup method should the user’s primary authentication method fail. This can happen for a variety of reasons, such as the phone running out of juice or a mobile network going down. Backup codes can only be used one time and are provided in batches.

Why choose WP 2FA

As we saw earlier, 2FA has the potential to bring a lot of benefits to the table. You can get even more benefits when choosing WP 2FA – the number 1 user-rated plugin that works with WooCommerce straight out of the box.

WP 2FA is more than a security plugin that protects your login forms from brute-force attacks. It offers tons of functionality that makes the implementation and functioning of 2FA easier for you and your WooCommerce and WordPress users alike.

One-click WooCommerce support

WP 2FA is an excellent choice for those running WooCommerce for many reasons, the primary of which is its out-of-the-box support for WooCommerce. You can very easily enable custom 2FA endpoints to add a 2FA menu option in the users’ portal.

You can also customize the menu label, ensuring it fits like a glove and does not stick out like a sore thumb.

Policies

WP 2FA uses policies to manage users’ 2FA, also allowing you to require users to use 2FA. You can easily set different policies by user role or set up one policy for all users – depending on how you want 2FA to work on your website. Policies also apply to WooCommerce users, helping you differentiate between staff and customers.

Policies allow for a fine degree of control. You can choose which 2FA to make available, whether you want to grant a grace period or not, and set up redirections if necessary.

White labeling

One of the most significant advantages of using WP 2FA for your WooCommerce 2FA deployment is its white labeling options. The plugin allows you to customize the 2FA screen with available options, including changing colors, text, logo, and font. You can also white-label the 2FA wizard, including adding your very own welcome screen and the text that appears in each step of the wizard.

Custom WooCommerce 2FA login screen

This high level of customization enables you to create a coherent brand experience for your users and customers. It ensures that whenever a customer or employee is setting up 2FA, they understand that it is your 2FA and can, as such, trust that they’re doing what they’re supposed to be doing.

Trusted devices

While 2FA is quite seamless, if some of your users are constantly logging in and out, it can prove to be a strain. This is where the trusted devices feature comes in. It allows you to give your most trusted users the ability to mark their devices as trusted. In turn, they avoid having to enter their 2FA code every time.

You retain full control at all times, and certain conditions must be met, such as using the same IP address and having a valid WordPress cookie.

Multiple 2FA methods

WP 2FA supports all of the 2FA methods discussed in the previous section. It also includes secondary 2FA methods to ensure customers do not get logged out. As such, you’ll be able to offer a wide variety of choices to ensure all of your customers can set up 2FA, regardless of how technologically savvy (or not) they are.

Equally, through secondary 2FA authentication methods, you can ensure customers will always be able to log in, even if their primary 2FA method fails – such as the phone running out of battery.

How to install 2FA for WooCommerce

To add 2FA to your WooCommerce store, you need WP 2FA – The number one rated two-factor authentication plugin for WordPress. It comes with out-of-the-box support for WooCommerce as well as extensive white-labeling options – a must if branding is important to you and your business.

You can easily purchase WP 2FA directly from the website. Once done, you’ll receive an email with a download link and your license key. The plugin comes in a ZIP file ready to be uploaded to your WordPress website.

Step 1: Install the plugin

In your WordPress dashboard, head to Plugins > Add New. Click on Upload Plugin, then click on Choose File. Locate the Zip File and install the plugin. You will need to enter your license key to activate the plugin.

Step 2: Set up 2FA

Once you activate the license, the setup wizard will kick in. The wizard will help you set up the basics of 2FA on your WordPress site. Of course, you can choose to quit the wizard and configure everything manually; however, the wizard helps you get up and running with the basic options in no time at all.

WordPress 2FA configuration wizard

If you decide to go ahead with the wizard, which we recommend, you are free to make any changes you want at any point through the plugin’s 2FA Policies page.

Step 3: Configure 2FA

Once you’ve set up 2FA, the wizard will ask you whether you want to configure 2FA for your account. By configuring 2FA for your account, you’ll ensure your account is safe and protected and be in a better position to advocate for 2FA with your users and customers.
Additional options

WP 2FA comes with a number of additional configuration options that allow you to customize your implementation of 2FA to your requirements. Options such as trusted devices, grace periods, and redirections (among others) can be set up by navigating to WP 2FA > 2FA Policies.

You can easily configure further settings, such as white labeling options, integrations, and security options, by navigating to WP 2FA > Settings.

For more detailed information on how to set up the plugin, refer to the WP 2FA documentation.

Step 4: WooCommerce integration

With WP 2FA you can add a custom 2FA WooCommerce endpoint, which provides customers with a 2FA configuration option in their portal menu.

To enable this integration, navigate to WP 2FA > Settings and click the Integrations tab. Tick the Enable checkbox and enter the Custom 2FA endpoint and Custom 2FA menu label.

WooCommerce 2FA integration settings

Nerd notes: What is an endpoint?

WooCommerce endpoints are URL appendages that allow WordPress to show specific content without needing a separate webpage. For example, the page /my-account/ has several endpoints, such as:

  • /order/
  • /edit-account/
  • /lost-passwords/

These endpoints are appended to the actual URL, allowing content to be served to the customer without requiring its own web page.

Manual integration

You can also add the endpoint manually if you’re using the free version of the plugin. You need to add the below custom code to your WordPress website.

We first need to create a custom endpoint. This custom endpoint will be the URL your users will visit to see the 2FA tab’s content.

// Create custom 2FA endpoint.
function wp_2fa_add_custom_config_endpoint() {
add_rewrite_endpoint( '2fa-config', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'wp_2fa_add_custom_config_endpoint' );
function wp_2fa_custom_query_vars( $vars ) {
$vars[] = '2fa-config';
return $vars;
}
add_filter( 'query_vars', 'wp_2fa_custom_query_vars', 0 );

Using the code above, your 2FA configuration page URL will read “domain.com/my-account/2fa-config/”. If you wish to change this, you can modify the variable value in the code provided above.

Now that we have set up the custom endpoint, we can add functionality to the endpoint. You need to add the below code to the functions.php file. It shows either the setup form or the login message – depending on whether the user is logged in or not.

function wp_2fa_custom_account_content() {
$logged_in = is_user_logged_in();
if ( $logged_in ) {
echo do_shortcode( '[wp-2fa-setup-form]' );
} else {
echo do_shortcode( 'You must be logged in to view this page. Login here.' );
}
}

It’s essential to always take a backup before manually adding code to WordPress files.

WooCommerce 2FA customer configuration

Once you have enabled 1-click WooCommerce 2FA integration in the WordPress admin, users and customers will be able to see the option to configure 2FA in their account, depending on how the 2FA policies for your WordPress have been set up.

WooCommerce customers can configure 2FA from their account page

All the user or customer needs to do to configure 2FA for their account is to click the CONFIGURE 2FA button, as shown in the screenshot above. This will automatically activate the 2FA configuration wizard, which will walk them through the entire process.

WooCommerce customers 2FA methods and options

Thanks to WP 2FA’s extensive customization and white labeling options, you can customize your WordPress users’ 2FA experience to match your branding and messaging. As such, the wizard may look different than the one shown in the screenshot above.

Frequently Asked Questions

What is the difference between 2FA and 2FA with backup codes?

2FA with backup codes works just like regular 2FA. The only difference is that backup codes are included for emergencies, such as your phone running out of battery. In such cases, you can use a backup code to gain entry while still abiding by the principles of two-factor authentication.

What are the benefits of 2 Factor Authentication?

2 Factor Authentication has many benefits. Increased security is the main benefit, with 2FA able to thwart the lion’s share of online attacks. It also allows for increased user mobility and an increase in customers’ trust, which can, in turn, will enable you to grow your WooCommerce store.

WordPress 2FA does not replace the need for strong passwords – both are required to ensure better security for your WooCommerce store.

What is the process for setting up WooCommerce 2FA?

Setting up WooCommerce 2FA is easy with WP 2FA. This WordPress plugin offers WooCommerce support straight out of the box and includes extensive white labeling options that allow you to brand your customers’ 2FA experience.

Posted inWordPress Security
Joel Farrugia
Joel Barbara

Joel is our technical writer responsible for writing the different kinds of content we need. With a background in tech and content, he has a passion for making technology accessible and understandable for everyone. You can reach Joel at joel@melapress.com.


Leave a Reply

Your email address will not be published. Required fields are marked *

Stay in the loop

Subscribe to the Melapress newsletter and receive curated WordPress management and security tips and content.

Newsletter icon

It’s free and you can unsubscribe whenever you want. Check our blog for a taste.

Envelope icon
newsletter-pop-up