Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait BasicAuthenticator {
- def basicUserAuthenticator(username: String, password: String)(implicit ec: ExecutionContext): AuthMagnet[UserPass] = {
- def validateUser(userPass: Option[UserPass]): Option[UserPass] =
- for {
- u <- userPass if u.user == username && u.pass == password
- } yield u
- def authenticator(userPass: Option[UserPass]): Future[Option[UserPass]] =
- Future(validateUser(userPass))
- BasicAuth(authenticator _, realm = "Private API")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement