Skip to content

Instantly share code, notes, and snippets.

@tjweir
Created March 25, 2009 15:40
Show Gist options
  • Select an option

  • Save tjweir/85530 to your computer and use it in GitHub Desktop.

Select an option

Save tjweir/85530 to your computer and use it in GitHub Desktop.
We have HTTP Basic Auth and HTTP Digest Auth support in Lift. The
authentication is implemented as a partial function that you implement
like so:
LiftRules.httpAuthProtectedResource.prepend {
case (ParsePath("api" :: _, _, _, _)) => Full(AuthRole("admin"))
}
LiftRules.authentication = HttpBasicAuthentication("lift") {
case (username, password, req) => {
User.find(By(User.username, username)) match {
case Full(user) if user.password.match_?(password) => {
userRoles(AuthRole("admin"))
true
}
case _ => false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment