PHPackages                             lucamauri/wiki2ban - 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. [Security](/categories/security)
4. /
5. lucamauri/wiki2ban

ActiveMediawiki-extension[Security](/categories/security)

lucamauri/wiki2ban
==================

Log failed MediaWiki login attempts to a file consumable by Fail2Ban

v1.1.0(1mo ago)678↓88.9%[2 issues](https://github.com/lucamauri/Wiki2Ban/issues)GPL-2.0-or-laterPHP

Since Apr 11Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/lucamauri/Wiki2Ban)[ Packagist](https://packagist.org/packages/lucamauri/wiki2ban)[ Docs](https://github.com/lucamauri/Wiki2Ban)[ RSS](/packages/lucamauri-wiki2ban/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)DependenciesVersions (7)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/710d0fa27bbdcd1faaa93108b706ecb09b70732437e8d35567bae3833c4df770/68747470733a2f2f706f7365722e707567782e6f72672f6c7563616d617572692f77696b693262616e2f76)](//packagist.org/packages/lucamauri/wiki2ban)[![Total Downloads](https://camo.githubusercontent.com/c99c6da47974f10c7e42066b22908d651d5cd2c7eba9c8e22fdca724662ce026/68747470733a2f2f706f7365722e707567782e6f72672f6c7563616d617572692f77696b693262616e2f646f776e6c6f616473)](//packagist.org/packages/lucamauri/wiki2ban)[![GPL v2 License](https://camo.githubusercontent.com/291fff67ba77b5a625fcbf83b291b6d1e9052be098195431d13f2dd6f1aaded4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d47504c76322d3030383033333f6c6f676f3d67706c)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)[![Built with Visual Studio Code](https://camo.githubusercontent.com/6e193a4267c3bac01ee23dc9f82d5d0f8c381f95089f6d80cb51073606c0547a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4275696c745f776974682d56535f436f64652d3030374143433f6c6f676f3d76697375616c73747564696f636f6465)](https://code.visualstudio.com)[![StyleCI](https://camo.githubusercontent.com/d8e02e8f0c828c76de90b739028cdcb20c39ef3b42aaa567f3b291790a564afe/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3333363333303331372f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/336330317?branch=master)

Wiki2Ban
========

[](#wiki2ban)

[![](https://camo.githubusercontent.com/71ea2ea230703466427bf4086b2550b3ec398f212717c61b9cc59629c41a9109/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f632f63652f5732424c6f676f2e737667)](https://camo.githubusercontent.com/71ea2ea230703466427bf4086b2550b3ec398f212717c61b9cc59629c41a9109/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f632f63652f5732424c6f676f2e737667)

Wiki2Ban (W2B) is a MediaWiki extension that logs failed authentication attempts to a file that [Fail2Ban](https://github.com/fail2ban/fail2ban) can read, enabling automatic IP banning of attackers.

This extension is inspired by [Extension:Fail2banlog](https://www.mediawiki.org/wiki/Extension:Fail2banlog), which is unmaintained and built for an older MediaWiki version. Wiki2Ban was written from scratch by [Luca Mauri](https://github.com/lucamauri), originally for [WikiTrek](https://github.com/WikiTrek), and released as open source for the broader MediaWiki community.

Features
--------

[](#features)

- Hooks into MediaWiki's authentication system to detect failed login attempts
- Writes a structured log line for each failure, including timestamp, username, wiki name, and client IP address
- Correctly resolves the client IP address behind reverse proxies and CDNs
- Log format is compatible with Fail2Ban out of the box
- Includes ready-to-use Fail2Ban filter and jail configuration files
- Includes an optional [Log Navigator](https://lnav.org/) format definition for interactive log analysis
- No database changes required
- Configurable log file path

Requirements
------------

[](#requirements)

- MediaWiki &gt;= 1.42.0
- PHP &gt;= 8.4
- [Fail2Ban](https://github.com/fail2ban/fail2ban) &gt;= 0.10 (for progressive banning support)

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

[](#installation)

The easiest way to install the extension is via *Composer*, which will automatically resolve all dependencies.

Add the following to `composer.local.json` at the root of your MediaWiki installation (create the file if it does not exist):

```
{
    "require": {
        "lucamauri/wiki2ban": "~1.1"
    },
    "extra": {
        "merge-plugin": {
            "include": []
        }
    }
}
```

Then run Composer from the root of your MediaWiki installation:

```
composer install --no-dev
```

Add the following line near the rest of the extension loading calls in `LocalSettings.php`:

```
wfLoadExtension('Wiki2ban');
```

Then add the configuration parameters described in the next section.

Configuration
-------------

[](#configuration)

Add the following to `LocalSettings.php`:

```
$wgW2BLogFilePath = "/var/log/mediawiki/wiki2ban.log";
```

### `$wgW2BLogFilePath`

[](#wgw2blogfilepath)

The full path to the log file that Wiki2Ban will write to and that Fail2Ban will monitor. The web server process must have write permission to this file and its parent directory.

Default value: `/var/log/mediawiki/wiki2ban.log`

Fail2Ban configuration
----------------------

[](#fail2ban-configuration)

After installing and configuring the extension, you need to configure Fail2Ban to monitor the log file. The `f2bconf/` directory in this repository contains ready-to-use configuration files.

### Filter

[](#filter)

Copy `f2bconf/w2bfilter.conf` to Fail2Ban's filter directory:

```
cp f2bconf/w2bfilter.conf /etc/fail2ban/filter.d/w2bfilter.conf
```

### Jail rule

[](#jail-rule)

Copy `f2bconf/w2brule.conf` to Fail2Ban's jail directory:

```
cp f2bconf/w2brule.conf /etc/fail2ban/jail.d/wiki2ban.conf
```

Then edit the file to set `logpath` to match the value of `$wgW2BLogFilePath` in your `LocalSettings.php`.

### Tuning for production

[](#tuning-for-production)

The default rule triggers after 5 failed attempts in 60 seconds and bans for 10 minutes. For a production wiki exposed to the internet, consider stricter values:

```
maxretry = 3
findtime = 300
bantime  = 86400
```

This bans an IP for 24 hours after 3 failures within 5 minutes. Progressive banning is enabled by default in the provided configuration — each repeated offence doubles the ban duration up to a maximum of one week.

After making changes, reload Fail2Ban:

```
sudo systemctl reload fail2ban
```

Troubleshooting
---------------

[](#troubleshooting)

To capture detailed debug log messages from Wiki2Ban, add the following to `LocalSettings.php`:

```
$wgShowExceptionDetails = true;
$wgDebugLogGroups['Wiki2Ban'] = "/var/log/mediawiki/Wiki2Ban-{$wgDBname}.log";
```

Optional: Log Navigator format
------------------------------

[](#optional-log-navigator-format)

`f2bconf/wiki2ban.json` is a format definition for the [Log Navigator](https://lnav.org/) application, which allows interactive exploration and filtering of the Wiki2Ban log file. See the [lnav format documentation](https://docs.lnav.org/en/latest/formats.html#defining-a-new-format) for installation instructions.

License
-------

[](#license)

[GNU General Public License, version 2 or later](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)

Maintainers
-----------

[](#maintainers)

[Luca Mauri](https://github.com/lucamauri)

Contributors
------------

[](#contributors)

[Luca Mauri](https://github.com/lucamauri)

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance87

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~1833 days

Total

2

Last Release

30d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dd8777d6a2cb6716bb24cef15643edf8f463a9ff9de1c3c7efeda0f1111cf342?d=identicon)[lucamauri](/maintainers/lucamauri)

---

Top Contributors

[![lucamauri](https://avatars.githubusercontent.com/u/433582?v=4)](https://github.com/lucamauri "lucamauri (32 commits)")

---

Tags

fail2banmediawikimediawiki-extensionphpphpsecuritymediawikifail2ban

### Embed Badge

![Health badge](/badges/lucamauri-wiki2ban/health.svg)

```
[![Health](https://phpackages.com/badges/lucamauri-wiki2ban/health.svg)](https://phpackages.com/packages/lucamauri-wiki2ban)
```

###  Alternatives

[asbiin/laravel-webauthn

Laravel Webauthn support

309574.8k](/packages/asbiin-laravel-webauthn)

PHPackages © 2026

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