As of r327 ClearPress has shipped with modules in the
ClearPress::authenticator:: namespace. These are helpers designed to
help authenticate users using various different mechanisms. At the
time of writing there are four mechanisms:
db.pm
principally for MySQL-backed accounts
ldap.pm
for LDAP and Active Directory
passwd.pm
for /etc/passwd (and NIS) support
session.pm
for cookie-based sessions
db, ldap and passwd verify username and password credentials whilst
session.pm verifies encrypted cookies from web-requests.
For simplicity let's assume the authentication procedure goes a
little like this:
Registered user "U" comes to app
U enters username and password and submits login form
username and password are checked in database (db.pm)
app serves welcome page with encrypted session cookie containing username+password
Further page requests from U return the session cookie
Each further page request decodes the session cookie and uses the username contained within (session.pm)
As well as the authenticator modules there are several other components required:
login page
logout page
a modified decor.pm for cookie handling
a 'user' data-model object
a modified controller.pm for building information about the requestor (the 'user' data model corresponding to the authenticated user)
Caveats
Symmetric encryption is performed using a secret key known to the webserver. If the key is compromised then it needs to be changed
If another user copies the cookie they will be authenticated as the user to whom the cookie belongs. Hence the use of SSL encrypting web traffic is advised
A few further measures may be used to improve security:
Use a private key per-user
Rotate the key per session
Time-out sessions after periods of inactivity
Re-verify periodically against the database in case an old cookie has been stolen