Tuesday, November 6, 2012

How To Secure Apache2 With LinOTP


This Howto describes the way to set up two factor authentication with one time passwords for Apache2. We assume, that you have already set up your LinOTP server. You can download Debian and Ubuntu packages or you can install the system using the Python Package Index. It provides a good quick start to get the service up and running for demo purposes (check for the latest version).


The OTP authentication is done using a Apache authentication provider for Apache basic authentication. This provider can be downloaded at github.
Or you can download the package directly at your command line:
wget https://github.com/lsexperts/mod_authn_linotp/zipball/master -O mod_authn_linotp.zip


You need at least the following packages on your Ubuntu or Debian system to compile the Apache module:
dpkg -i libtool automake autoconf build-essential libcurl4-gnutls-dev
Now unzip the module and enter the directory:
unzip mod_authn_linotp.zip
cd lsexperts-mod_authn_linotp-3583b90
The installation process is also described in the file INSTALL:
automake --add-missing
sudo make install
You can also use checkinstall to create a debian package for easier package handling.
sudo checkinstall make install
Now the module is located at /usr/lib/apache2/modules/mod_authn_linotp.so.

Activate the module

sudo a2enmod authn_linotp

Configure Apache

Now you can use two factor authentication for your Apache directories and locations. You can also take a closer look at the file README for all the configuration parameters.
The module uses cookies to cache the successful authentication. The cookie is encrypted, so you need to create a secret:
pwgen 24 1
Now you can protect any Directory or Location scope like this:

    AuthType basic
    AuthName "LinOTP protected"
    AuthBasicProvider LinOTP
    Require valid-user
    LinOTPCookieSecret  eenohJaen6CeexaH9yieTiel
    LinOTPSSLCertVerify Off
    LinOTPSSLHostVerify Off
Using LinOTPTimeout you can define for how many seconds the cookie should be valid and thus after which time the user should be asked for a new OTP again.
Please note: Using localhost in you LinOTPValidateURL might lead to curl errors, so please either use the correct IP or FQDN.
Happy Authenticating!

No comments:

Post a Comment