**Title:** Auth Redux

**Description:** 

**Details:**
Auth Redux is a drop-in replacement for the builtin authentication handler of Minetest. It is designed from the ground up to be robust and secure enough for use on high-traffic Minetest servers, while also addressing a number of outstanding engine bugs (including #5334 and #6783 and #4451) as described last year in the [Critical bug in builtin authentication handler](https://forum.minetest.net/viewtopic.php?f=6&t=16656) forum topic.

Auth Redux is completely Lua-driven, with no external dependencies. It interfaces seamlessly with Minetest's authentication handler API, therefore no complicated setup or configuration is required. It is intended to be compatible with all versions of Minetest 0.4.14+ and 5.x and has been successfully tested under CentOS7, Windows 10, and Windows XP.

For the latest release notes, as well as technical support requests, please visit the forum topic.

## Overview

Auth Redux provides an efficient and scalable back-end solution for player authentication, making it suitable for even the most demanding server environments. It has been put to the test with a database of over 520,000 registered users -- with no in-game overhead!

* **High-Performance Journaling System.**
To protect the master database against corruption and data loss, all transactions are serially recorded within a journal, thereby reducing the frequency and intensity of disk writes. In the event of a server crash or power outage, any pending transactions are committed to the master database.

* **Simple Ruleset-Based Login Filtering.**
MARS is an easy-to-learn scripting language that affords a first line of defense against unwanted visitors. Both restrictive and permissive security models can be enforced via rulesets, allowing every login request to be filtered according to conditional action-chains with custom error messages.

* **Expanded Master Database Schema.**
The master database supports additional metadata to aid in reviewing and monitoring login activity, including the timestamp of the first login, the total time spent playing, the total number of player sessions, etc. This information can prove invaluable for command-line reporting and analysis tools.

The project is a WIP and will be undergoing continuous development based upon your suggestions and feedback. New features and bug-fixes will be announced here as they become available.

## Installation:

Only a few basic steps are required to begin using the Auth_Redux mod immediately with your server.

1. Unzip the archive into the mods directory of your game
2. Rename the auth_rx-master directory to "auth_rx"
3. Execute the conversion scripts (see usage instructions below)

Linux distributions already include the awk command-line utility, so no additional setup is required. However Microsoft Windows users will need to install Gawk for Windows.

## Basic Database Import:

If you intend to use Auth Redux with an existing world, then the default authentication database must be converted. A simple awk script is made available for this purpose. It is located within the 'tools' subdirectory.

The following commands will begin the conversion process. Depending on the size of your auth.txt file, it may take several seconds to complete:

    > cd auth_rx/tools
    > awk -f convert.awk -v mode=convert ~/.minetest/worlds/world/auth.txt

Since the original 'auth.txt' file is no longer needed, it should be renamed for safe-keeping and to prevent conflicts. If you perform daily backups of your world directory, then it is strongly recommend that you archive these three files:

* auth.db - master database
* auth.dbx - transaction log
* greenlist.mt - ruleset definition

Both files must have read and write permissions. The master database and transaction log should never be removed nor modified directly.

If you are creating a new world, then you can initialize the master database using the same command as above. Simply, create an empty 'auth.txt' file beforehand.

## Command-Line Analytics Script

The transaction log of Auth Redux has always served a dual purpose. Besides protecting against data loss and corruption, it also permits efficient reporting and analysis. With this release, I've included a command-line analytics script for just this purpose!

You can review wide variety of server and player metrics for any given 24-hour period:

* Total Players - total number of unique players that joined per day
* Total New Players - total number of new players that joined per day
* Total Player Sessions - total number of player sessions per day
* Total Login Failures - total number of failed logins per day
* Total Login Attempts - total number of attempted logins per day
* Overall Server Uptime - aggregate uptime percentage of the server per day
* Maximum Connected Clients - maximum number of connected clients per day
* Minimum Connected Clients - minimum number of connected clients per day
* Maximum Player Lifetime - maximum session duration amongst all players per day
* Average Player Lifetime - average session duration amongst all players per day

Most of these statistics are also broken up into an hour-by-hour format. The following statistics are player-specific:

* Total Sessions - total number of sessions of each player
* Total Lifetime - aggregate session duration of each player

Generating reports of player login activity is both quick and easy. It can even be accomplished while the server is still online. From the shell, change to the tools subdirectory and issue the following command:

```
cd auth_rx/tools
awk -f report.awk -v days=1 -v type=txt ~/.minetest/worlds/new_survival/auth.dbx
```

Given a "days" parameter of 1 and a type parameter of "txt" ,this will analyze the journal file in the "new_survival" world, and generate a plain-text report of player login activity for yesterday. Changing the "days" parameter to 0 will obtain data from today. So on and so forth.

You can optionally redirect output to a file or even pipe to another command. This would be useful for receiving automated daily reports by email. By changing the "type" parameter to `js`, the results will be formatted as a JSON for embedding into a dynamic Website. Here is a very simple DHTML page with an AJAX request. Of course you are free to custom-tailor the output entirely to your needs.

**Tags:** complex_installation, server_tools
**Repository:** https://bitbucket.org/sorcerykid/auth_rx
**License:** MIT