mozilla / mod_authnz_persona

A persona authentication module for apache
Apache License 2.0
23 stars 15 forks source link

mod_authnz_persona is a module for Apache 2.0 or later that allows you to quickly add Persona authentication to a site hosted with Apache.

Installation

First, install the dependencies:

Red Hat Enterprise Linux Derivative distributions

Build yajl 2.0

yum install httpd httpd-devel curl-devel cmake
wget http://fedora.mirror.nexicom.net/linux/development/rawhide/source/SRPMS/y/yajl-2.0.4-3.fc20.src.rpm
rpmbuild --rebuild yajl-*.src.rpm
sudo yum install ~/rpmbuild/RPMS/`uname -i`/yajl-*.rpm

Clone the source and build

git clone https://github.com/mozilla/mod_authnz_persona.git
cd mod_authnz_persona
make
sudo make install

Debian/Ubuntu Derivative distributions

Install yajl 2.0

wget https://launchpad.net/ubuntu/+source/yajl/2.0.4-2/+build/3450133/+files/libyajl2_2.0.4-2_amd64.deb
wget https://launchpad.net/ubuntu/+source/yajl/2.0.4-2/+build/3450133/+files/libyajl-dev_2.0.4-2_amd64.deb
sudo dpkg -i libyajl2_2.0.4-2_amd64.deb libyajl-dev_2.0.4-2_amd64.deb

Clone the source and build

sudo apt-get install make git gcc apache2 apache2-threaded-dev libcurl4-gnutls-dev
git clone https://github.com/mozilla/mod_authnz_persona.git
cd mod_authnz_persona
APXS_PATH=/usr/bin/apxs2 make
sudo APXS_PATH=/usr/bin/apxs2 make install

Configuration

Configure the module:

LoadModule authnz_persona_module modules/mod_authnz_persona.so

<Location />
   AuthType Persona
   Require valid-user
   # Or, require users with host/IdP example.com:
   # Require persona-idp example.com
   # Or, require specific users (requires mod_authz_user)
   # Require user user@example.com
</Location>

This will cause the module to require Persona authentication for all requests to the server.

Features

How it works

The module works by intercepting requests bound for protected resources, and checking for the presence of a session cookie.

If the cookie is not found, the user agent is served an HTML document that presents a Persona login page.

Note that the authentication request to the Persona server includes the server's hostname and thus either hostname -f or the value of ServerName must match the domain portion of the URL to avoid failing with an “audience mismatch: domain mismatch” error.

Upon successful authentication with Persona, this page will send a request to the server with a Persona assertion in an HTTP header. The module, upon detecting no cookie is present, will look for this header, validate the assertion, and set a short session cookie.

The authentication page will then reload the desired resource.

Further configuration settings