Basic Http authentication in Lift.

Table of contents
Reading Time: 2 minutes

Lift web framework accommodate a no. of conspicuous features that are implemented in a unique and solitary way as compared to other frameworks. Here we’ll discuss about the basic “Http authentication” mechanism for security in Lift.

What is ‘LiftRules’ singleton ?
Nearby all configuration parameters for the http requests and response are defined in LiftRules singleton. The important thing to notice is that we can only change the configuration parameteres of LiftRules only during boot but not at other times. You can find more about LiftRules Here.

Now for our purpose of Http authentication what all you have to do , is to add some Lines of code using the LiftRules singleton present in lift, in to your Boot.scala File and you’ll find all gets done for a basic http authentication.

Let us have a look to the steps for doing it ::

*Firstly in your Boot.scala file make the class extends Loggable(part of “net.liftweb.common”) as :

*Now you have to proceed with the ‘prepend’ method(from LiftRules package) implementation in your Boot(def Boot) method & defining the name of html pages on which you want to implement the authentication as follows:

*Call the authentication(have root in ‘HttpAuthentication.class’) from the LiftRules and mention the username and password for the authentication purpose as :


* Now each time when user will try to access the page,browser will pop up for the http authentication like: 🙂

Http Authentication in Lift

Note:- Don’t forgot the following basic imports:

::: Want to get start with Lift ? come Here.