PHPackages                             bitexpert/magento2-force-customer-login - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. bitexpert/magento2-force-customer-login

ActiveMagento2-module[Authentication &amp; Authorization](/categories/authentication)

bitexpert/magento2-force-customer-login
=======================================

The Force Login module for Magento2 redirects a storefront visitor to the Magento2 Frontend login page, if the visitor is not logged in. It is possible to configure the whitelisted urls to add custom definitions.

5.4.0(2y ago)171409.9k↓24%74[2 PRs](https://github.com/bitExpert/magento2-force-login/pulls)Apache-2.0PHPPHP ~8.1.0|~8.2.0|~8.3.0

Since Apr 19Pushed 2y ago11 watchersCompare

[ Source](https://github.com/bitExpert/magento2-force-login)[ Packagist](https://packagist.org/packages/bitexpert/magento2-force-customer-login)[ RSS](/packages/bitexpert-magento2-force-customer-login/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (13)Versions (59)Used By (0)

Force Login Module for Magento® 2
=================================

[](#force-login-module-for-magento-2)

[![Build Status](https://github.com/bitExpert/magento2-force-login/workflows/ci/badge.svg?branch=master)](https://github.com/bitExpert/magento2-force-login/actions)[![Coverage Status](https://camo.githubusercontent.com/88cec960df468b39cf0e73acec120c32a28e79ee3e2bff0598521cb50411c9ce/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6269744578706572742f6d6167656e746f322d666f7263652d6c6f67696e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/bitExpert/magento2-force-login?branch=master)[![Mastodon Follow](https://camo.githubusercontent.com/c2abd2d790b2fdf042e992e8872c59044086bdb16b119a61d8526d6238c3c2ba/68747470733a2f2f696d672e736869656c64732e696f2f6d6173746f646f6e2f666f6c6c6f772f3130393430383638313234363937323730303f646f6d61696e3d68747470733a2f2f726865696e6e65636b61722e736f6369616c)](https://rheinneckar.social/@bitexpert)

The **Force Login** Module for *Magento® 2* allows you to restrict which pages a visitor is able to see. Visitors get redirected to the login page if the page is not marked visitable. The **Force Login** Module for *Magento® 2* is especially useful for merchants serving only a specific group of users, e.g. enterprise related business partners and need to ensure that only those users are able to browse the the website or the product catalog.

Features:
---------

[](#features)

- Force your guest visitors to log in first (or register), before allowing them to visit your pages and catalog
- Administration: Manage the whitelist rules by the GUI in the administration area
- ACL: Restrict the administration of whitelist rules to certain backend user groups
- Whitelisting: Define url rules as pattern to define which pages guest visitors can visit without logging in first
- Multistore-Support: Define if whitelist rules either apply globally or for specific stores
- [Hyvä Themes](https://hyva.io) compatible

Requirements:
-------------

[](#requirements)

- PHP 7.4 or PHP 8.1
- Magento 2.4.0 or higher

Installation
------------

[](#installation)

The preferred way of installing `bitexpert/magento2-force-customer-login` is through Composer. Simply add `bitexpert/magento2-force-customer-login`as a dependency:

```
composer.phar require bitexpert/magento2-force-customer-login

```

Optional you can download the latest version [here](https://github.com/bitExpert/magento2-force-login/releases) and install the decompressed code in your projects directory under *app/code/BitExpert/ForceCustomerLogin*.

#### Composer error package bitexpert/magento2-force-customer-login exists

[](#composer-error-package-bitexpertmagento2-force-customer-login-exists)

When you have errors after installing trough composer there is probably an issue with version numbers between Packagist and Magento repo. You can update your project composer file to fix this:

```
{
  "repositories": [
    {
      "type": "composer",
      "url": "https://repo.magento.com/",
      "canonical": false
    }
  ]
}

```

Post-Install
------------

[](#post-install)

After the installment of the module source code, the module has to be enabled by the *Magento® 2* CLI.

```
bin/magento module:enable BitExpert_ForceCustomerLogin

```

System Upgrade
--------------

[](#system-upgrade)

After enabling the module, the *Magento® 2* system must be upgraded.

If the system mode is set to *production*, run the *compile* command first. This is not necessary for the *developer* mode.

```
bin/magento setup:di:compile

```

To upgrade the system, the *upgrade* command must be run.

```
bin/magento setup:upgrade

```

Clear Cache
-----------

[](#clear-cache)

At last, the *Magento® 2* should be cleared by running the *flush* command.

```
bin/magento cache:flush

```

Sometimes, other cache systems or services must be restarted first, e.g. Apache Webserver and PHP FPM.

User Guide
==========

[](#user-guide)

Find the complete user guide [here](./docs/UserGuide.pdf "User Guide").

How to use
----------

[](#how-to-use)

The usage of the **Force Login** Module for *Magento® 2* is applied implicitly by redirecting visitors if the called URI does not match any configured whitelisted url rules.

### Whitelisting

[](#whitelisting)

Whitelisting is based upon the usage of rules. The strategy selection defines how the rules are interpreted, [details are listed below](#strategies). By default, some static rules are already listed. The following example shows, how to add a whitelist entry for the homepage (startpage).

Navigate to the **Overview Grid** and use the *Add Entry* button.

- Enter **Homepage** into the text field beside from the **Label** label.
- Enter **^/?$** into the text field beside from the **Url Rule** label.
- Select **All Stores** from the selection field beside from the **Store** label.

Use the **Save** button in the upper menu. After being redirected to the **Overview Grid**, the new entry should appear to the list and the systems homepage should be available for guest visitors.

How to configure
----------------

[](#how-to-configure)

### Administration

[](#administration)

The **Force Login** Module for *Magento® 2* allows you to enable or disable the module itself on the level of websites, stores and store views.

If the module is *disabled*, the whitelist ruling and the redirection are not applied. If the module is *enabled* based upon the configuration, the whitelist rules are process, which themselves are also configurable for all enabled stores or just specific ones.

After installing and enabling **Force Login** Module for *Magento® 2* with the CLI, you must be able to navigate to *Stores &gt; Configuration &gt; Force Login*, where you are able to configure the availability of the module for each website, store and store view.

In the administration configuration, you are also able to setup the URL the redirecting is targeting to if not whitelist rule is matching.

[![alt text](./resources/ui_step_00.png "Administration")](./resources/ui_step_00.png)

### Navigation

[](#navigation)

Navigating through the *Magento® 2* backend menu by clicking onto **Customers** you must see a new menu entry **Forced Login Whitelist**.

Enter this menu entry.

[![alt text](./resources/ui_step_01.png "UI Navigation")](./resources/ui_step_01.png)

### Overview Grid

[](#overview-grid)

You can add new entries by clicking on the *Add Entry* button in the upper right corner ( **1** ), [see below](#detail-form). The grid ( **2** ) contains all existing whitelisted *Url Rules*, for which the forced redirect to the *Customer Login Page* is omitted. The *Url Rules* ( **3** ) are part of a regular expression checking on the called *Url* and tries to match against the whitelist. *Url Rules* may be related to all stores or to a specific one ( **4** ). All rules except some mandatory ones are editable ( **5** ) and removeable ( **6** ).

[![alt text](./resources/ui_step_02.png "UI Grid")](./resources/ui_step_02.png)

### Detail Form

[](#detail-form)

You can return to the *Overview Grid* by using the *Back* button ( **1** ). The *Label* value has only declarative character and is for information purpose only ( **2** ). The *Url Rule* is an expression checking on the called *Url* and tries to match against the whitelist ( **3** ). *Url Rules* may be related to all stores or to a specific one ( **4** ). The strategy selection ( **5** ) defines how the *Url Rule* is interpreted, [details are listed below](#strategies). Persist the rule by using the *Save* button ( **6** ).

[![alt text](./resources/ui_step_03.png "UI Form")](./resources/ui_step_03.png)

### Strategies

[](#strategies)

#### Static

[](#static)

Rule is used as a literal value and will be added onto the base url for matching. This is default behaviour.

#### RegEx-All

[](#regex-all)

Rule is based on [regular expression](https://en.wikipedia.org/wiki/Regular_expression), and will be used for looking up matching anywhere in the current Url.

#### RegEx-All Negation

[](#regex-all-negation)

Based on the *RegEx-All* strategy, but negates the result. Helpful if only a few pages should be restricted.

Tests
-----

[](#tests)

You can run the unit tests with the following command (requires dependency installation):

```
composer test

```

Contribution
------------

[](#contribution)

Feel free to contribute to this module by reporting issues or create some pull requests for improvements.

License
-------

[](#license)

The **Force Login** Module for *Magento® 2* is released under the Apache 2.0 license.

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity55

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity92

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 85.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~68 days

Recently: every ~179 days

Total

44

Last Release

747d ago

Major Versions

1.3.1 → 2.0.0-RC12017-03-23

2.3.0 → v3.0.02017-12-25

3.2.0 → 4.0.02019-11-02

4.1.0 → 5.0.02022-05-13

PHP version history (10 changes)1.0.0PHP ~5.5.0|~5.6.0|~7.0.0

2.0.0-RC1PHP ~5.6.0|~7.0.0

2.2.0PHP ~7.0|~7.1

3.0.1PHP ~5.6.5|7.0.2|7.0.4|~7.0.6|~7.1.0

3.2.0PHP ~5.6.5|7.0.2|7.0.4|~7.0.6|~7.1.0|~7.2

4.0.0PHP ~7.1.3|~7.2|~7.3

4.1.0PHP ~7.1.3|~7.2|~7.3|~7.4

5.0.0PHP ~7.3.0|~7.4.0|~8.1.0

5.2.0PHP ~8.1.0|~8.2.0

5.4.0PHP ~8.1.0|~8.2.0|~8.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1adf0ab660536efce10aeb97f0c90ec881110b64fbd23429fa945190df0def56?d=identicon)[shochdoerfer](/maintainers/shochdoerfer)

---

Top Contributors

[![shochdoerfer](https://avatars.githubusercontent.com/u/596449?v=4)](https://github.com/shochdoerfer "shochdoerfer (177 commits)")[![kimsondrup](https://avatars.githubusercontent.com/u/8328984?v=4)](https://github.com/kimsondrup "kimsondrup (5 commits)")[![lracicot](https://avatars.githubusercontent.com/u/362115?v=4)](https://github.com/lracicot "lracicot (4 commits)")[![rikwillems](https://avatars.githubusercontent.com/u/5927342?v=4)](https://github.com/rikwillems "rikwillems (3 commits)")[![viniqueiroz](https://avatars.githubusercontent.com/u/11986048?v=4)](https://github.com/viniqueiroz "viniqueiroz (3 commits)")[![philippsander](https://avatars.githubusercontent.com/u/4118369?v=4)](https://github.com/philippsander "philippsander (2 commits)")[![artem-schander](https://avatars.githubusercontent.com/u/1243826?v=4)](https://github.com/artem-schander "artem-schander (2 commits)")[![mattyl](https://avatars.githubusercontent.com/u/445187?v=4)](https://github.com/mattyl "mattyl (1 commits)")[![mirsch](https://avatars.githubusercontent.com/u/6177906?v=4)](https://github.com/mirsch "mirsch (1 commits)")[![nalinsavaliya](https://avatars.githubusercontent.com/u/15698953?v=4)](https://github.com/nalinsavaliya "nalinsavaliya (1 commits)")[![peterjaap](https://avatars.githubusercontent.com/u/431360?v=4)](https://github.com/peterjaap "peterjaap (1 commits)")[![vmalyk](https://avatars.githubusercontent.com/u/5318027?v=4)](https://github.com/vmalyk "vmalyk (1 commits)")[![xaevik](https://avatars.githubusercontent.com/u/62903002?v=4)](https://github.com/xaevik "xaevik (1 commits)")[![bold-dkdewijer](https://avatars.githubusercontent.com/u/103425939?v=4)](https://github.com/bold-dkdewijer "bold-dkdewijer (1 commits)")[![chedaroo](https://avatars.githubusercontent.com/u/3003877?v=4)](https://github.com/chedaroo "chedaroo (1 commits)")[![finelinejacobs](https://avatars.githubusercontent.com/u/56639339?v=4)](https://github.com/finelinejacobs "finelinejacobs (1 commits)")[![iranimij](https://avatars.githubusercontent.com/u/31434218?v=4)](https://github.com/iranimij "iranimij (1 commits)")[![joachimVT](https://avatars.githubusercontent.com/u/1216688?v=4)](https://github.com/joachimVT "joachimVT (1 commits)")[![juhanihaapala](https://avatars.githubusercontent.com/u/3079827?v=4)](https://github.com/juhanihaapala "juhanihaapala (1 commits)")

---

Tags

force-loginmagento2magento2-extensionmagento2-modulephpwhitelist-login

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bitexpert-magento2-force-customer-login/health.svg)

```
[![Health](https://phpackages.com/badges/bitexpert-magento2-force-customer-login/health.svg)](https://phpackages.com/packages/bitexpert-magento2-force-customer-login)
```

###  Alternatives

[mollie/magento2

Mollie Payment Module for Magento 2

1121.6M10](/packages/mollie-magento2)[dotdigital/dotdigital-magento2-extension

Dotdigital for Magento 2

50374.2k18](/packages/dotdigital-dotdigital-magento2-extension)[swissup/module-search-mysql-legacy

Legacy mysql search for magento 2.4

10483.0k](/packages/swissup-module-search-mysql-legacy)[fredden/magento2-module-javascript-error-reporting

A Magento 2 module which captures JavaScript errors for later review by website administrators

3138.1k](/packages/fredden-magento2-module-javascript-error-reporting)[loki/magento2-admin-components

N/A

151.6k5](/packages/loki-magento2-admin-components)[pagbank/payment-magento

PagBank - Payment for Magento and Adobe

2128.3k7](/packages/pagbank-payment-magento)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
