Created
March 25, 2009 15:40
-
-
Save tjweir/85530 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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