DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:twofactor

Two Factor Authentication - Core Plugin

Compatible with DokuWiki

  • 2018-04-22 "Greebo" yes
  • 2017-02-19 "Frusterick Manners" yes
  • 2016-06-26 "Elenor Of Tsort" yes
  • 2015-08-10 "Detritus" yes

plugin Provides modular two factor authentication functionality to DokuWiki

Last updated on
2018-10-22
Provides
Admin, Action
Repository
Source
Requires
attribute

Similar to authgoogle2fa

Tagged with 2fa, authentication, security, two-factor

Summary

This module provides a two factor authentication framework to a wiki. It is designed to work with any wiki-based authentication mechanism that supports the 'getUsers' method (see below for additional information). This module requires at least one Two Factor authentication module (listed below) in order to work.

ANOTHER MAJOR REVISION

As of 2018-06-28, I have changed one of the methods in this module that breaks all prior versions of child modules. I have updated all the modules, so as long as you update ALL twofactor modules, this should not be an issue.

Installation

Install the plugin and at least one supporting module. Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

This plugin requires configuration prior to being functional. However, it will not interfere with any existing authentication plugin. This plugin “wraps” the authentication module by preventing the user from accessing the wiki until the two factor challenge is completed.

Depending on how the Two Factor module is configured, users will be able to continue to use the wiki without using two factor authentication.

Two Factor Modules

  • Email – Send a one-time password to a user using their DokuWiki registered email address.
  • Alternate Email – Send a one-time password to a user using an email address that is not registered with DokuWiki.
  • Google Authenticator – Allow the use of Google Authenticator to generate login tokens.
  • SMS via Email Gateway – Send a one-time password to a user's cell phone using an email gateway.
  • SMS via Appliance – Send a one-time password to a user's cell phone using an SMS appliance.

How It Works

This is NOT an authentication plugin. Instead, it is a display barrier between your users and the wiki. When a user logs in but has not completed two factor authentication, they are guided to the Two Factor configuration page to configure it (if mandatory for the wiki) or to a separate screen where they can enter any received One-Time Passwords (OTP). This means that conceptually, this should work with ANY authentication plugin. As of Detritus, I have used this with authad in production and authplain in development with great success. Please post if you have success with other back-ends!

User Setup

User Configuration Page

In order to use two factor authentication, the user will have to first configure their own two factor settings if any additional modules require it. This setup can be done through the Two Factor configuration page.

Unless the wiki uses mandatory two factor authentication, each user will have a master checkbox to turn on and off two factor authentication. When turned on, the user will then have the option to turn on and off the use of any installed modules. If the user turns on the use of a module, the user will have to verify that the module works for them by either supplying the correct token or one-time password. After the user has verified that it is working, the wiki will then allow that module to be used for two factor authentication.

The user may use any one of the modules they have configured to two factor authenticate, so configuring both Google Authenticator and and alternate email one-time password allows the user to use either method to login. Keep in mind that in order for multiple modules to be effective, the modules should not have a single point of failure, e.g. configuring Google Authenticator and SMS messages doesn't work if the user loses their cell phone.

User Login

If a module supports token-based authentication, like Google Authenticator, the token must be supplied at the login page. If the user is not using a token based method, such as a one-time password via SMS message, the user leaves that field blank at the login page and will be redirected to a separate page to supply the one-time password.

Any user that has not configured two factor authentication can login without supplying a token or one-time password, and will be redirected to the Two Factor configuration page if two factor authentication is required by the wiki admin.

Admin Page

There is an admin page to enable the reset of two factor settings for users that manage to get locked out. Face it, cellphones get lost and people mistype data in fields, so it's gonna happen…

Once in the admin page, check the box next to the user whose account you want to reset, then click the Reset selected button. This removes all user settings, and they will have to completely reconfigure their two factor setup from the beginning. There is no option to individually manage their settings to prevent tampering.

Configuration and Settings

  • enable – Turn on or off all two factor authentication functionality. Default: off
  • optinout – Configure two factor features as optin, optout, and mandatory. Default: optin
  • otpsubject – A subject for OTP messages sent to the user. Default: OTP Verification Code
  • otpcontent – The message to deliver to the user. $otp is replaced with the randomly generated code. Default: $otp is your verification code.
  • generatorexpiry – How many windows of time a GA code is valid for. This setting allows for a code to be useful for longer than its display time in GA. Very helpful for slow typing users of if a code is seen at the end of its display time. Default: 2 (the time displayed plus one more code)
  • otplength – Length of the randomly generated OTP. Default: 7
  • sentexpiry – Time in minutes that a sent OTP is valid for. Default: 5
  • loginnotice (Not working yet) – Send a notice on successful login to the user. Options are never (none), user choice (user), and always send a message (always). Default: user
  • loginsubject – A subject for login confirmation messages sent to the user. Default: Login Successful
  • logincontent – The login message to deliver to the user. $time is replaced with the time as generated by date(RFC_2822). Default: Your account was logged into at $time.
  • refreshexpiry – A second login cookie is set by twofactor after the user has completed teh second login. This is the server-side timeout for that cookie, in minutes. Must be between 5 and 1440 minutes. Default: 240
  • logging_level – Sets the logging level of the module. Supports five options: None, Audit, Audit+, Debug, and Debug+. The Audit settings are appropriate as a login/logoff audit trail. Debug settings can be sent to me to assist in debugging. The “'Debug+' option will also provide stack traces. The log file is intended to be CSV friendly. Default: None
  • logging_path – Path and filename of the log file written. Relative paths default to the wiki data directory. Absolute paths are honored to the extent PHP permits. Default: 2fa_audit.txt

Development

Additional work will be based on my free time in the future. I was allowed to put this together for my work and release it, but future development will be on my personal time.

API

The authmod.php file in the module is the base abstract class that can be used to add a custom authentication module. Please review the file to learn more.

Change Log

Known Bugs and Issues

  • None that I'm aware of. Visit the GitHub page for each of the modules for more information (or to let me know that something is broken).

ToDo/Wish List

  • I've had a request to add Twilio and Plivo as supported two factor resources. After the redesign, I will look into it. I will need some help for testing, my personal budget is zero dollars and zilch cents.
  • Possibly supply a configuration setting enabling the admin to designate which characters to use in the OTP generator. Right now it is fixed on Arabic numerals.

YOUR Help

I originally wrote this because we needed 2FA for our wiki at work. Our use of DokuWiki has come to a close, but I will continue to maintain this code for the foreseeable future on my own time. That said, I will post fixes that are brought to my attention and test it our in my development environment as best as possible, but now I need your help to confirm that it is working. Also, please let me know that this update does or does not work with the current stable release so I can update this compatibility page.

FAQ

WIP. I will pull discussion questions and post them here as blatant questions come up.

Big Thanks / Acknowledgement

First, I want to thank my employer, Antelope Valley College, for allowing me to release this code to the open source community.

A big thanks goes out to Dan Popp for the work on his Google 2FA plugin – it provided me with the idea, libraries, and a code template to get this project started.

Another big thanks to Christopher Smith and the developers that worked on the User Manager Plugin. I used their admin code as the basis for my plugin and have to give them credit for their work that I used.

Discussion

Feel free to write anything constructive. My hope is that this plugin will provide many admins with useful functionality.

plugin/twofactor.txt · Last modified: 2018-10-22 08:33 by wilminator