Advertisement
Guest User

Untitled

a guest
Jan 26th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. trait BasicAuthenticator {
  2.  
  3. def basicUserAuthenticator(username: String, password: String)(implicit ec: ExecutionContext): AuthMagnet[UserPass] = {
  4. def validateUser(userPass: Option[UserPass]): Option[UserPass] =
  5. for {
  6. u <- userPass if u.user == username && u.pass == password
  7. } yield u
  8.  
  9. def authenticator(userPass: Option[UserPass]): Future[Option[UserPass]] =
  10. Future(validateUser(userPass))
  11.  
  12. BasicAuth(authenticator _, realm = "Private API")
  13. }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement