This is part 3 of a series of posts describing a
proof-of-concept web app that implements cryptographic authentication
using Node.js with a MongoDB back-end. Part
1 described the login process. Part
2 described the registration process. This Part 3 is
concerned with login session maintenance in a broader scope than
cryptographic authentication.
Part 4, concerned with random bit generation, is now available.
The proof-of-concept app, called
app-mongodb.js, can be found in a zip file downloadable
from the cryptographic
authentication page.
Update. The name of the constant securityStrength
has been changed to rbgSecurityStrength as noted in the last post of the series and reflected in one of the snippets below.
At first glance it may seem that there is no need for login
session maintenance in a web app that implements cryptographic
authentication with a key pair. Every HTTP request can be
authenticated on its own without linking it to a session, by sending
the public key to the back-end and proving possession of the private
key, as in the login process described in Part 1. That login process
relied on the user supplying the username in order to locate the user
record, but this is not essential, since the user record could be
located in the database by searching for the public key, which is
unique with overwhelming probability.
But login sessions provide important login/logout functionality,
allowing the user to choose whether to authenticate or not. A member
of a site accessible to both members and non-members, for example, may
choose to visit the site without authenticating in order to see what
information is made available by the site to
non-members. Also, the proof of possession of the private key has a
latency cost for the user due to the need to retrieve the challenge
from the server, and a computational cost for the server and the
browser. These costs are insignificant if incurred once per session,
but may not be insignificant if incurred for every HTTP request.
The app discussed in this series, app-mongodb.js,
implements login sessions in the traditional way using session
cookies. Having said that I could stop here. But the Express framework used in the app
provides interesting ways of implementing traditional login sessions,
which are worth discussing.
Continue reading “Login Session Maintenance in Node.js using Express and Handlebars”