Uses Basic Auth to control access to the whole of a Lift application based on the run mode. Useful, for example, when you want to restrict access to a site before launch or restrict access to a staging site.
Add the following repository to your SBT project file:
For SBT 0.10:
resolvers += "liftmodules repository" at "http://repository-liftmodules.forge.cloudbees.com/release/"
For SBT 0.7:
lazy val liftModulesRelease = "liftmodules repository" at "http://repository-liftmodules.forge.cloudbees.com/release/"
Include this dependency:
"net.liftmodules" %% "basic-auth" % (liftVersion+"-1.2")
In your application's Boot.boot code:
Finally, add the following properties to the properties files of the run mode you wish to be protected. For example, add the following to
src/main/resources/production.default.propsIf you want all run modes to have authentication put them in default.props
liftmodules.basic.title=Protected Site liftmodules.basic.username=hello liftmodules.basic.password=hello
If there are paths you wish to exclude from authentication use the
liftmodules.basic.paths property. This is a comma separated list of paths. We only match on the first part of the context path, e.g
liftmodules.basic.paths=moose will give unauthorized access to any URL with the context path starting with moose e.g. http://localhost:8080/moose/id/123