Last active
June 10, 2016 11:15
-
-
Save JoolsF/2fdce9c16c29a8511ce83992bbb31aa8 to your computer and use it in GitHub Desktop.
Basic auth akka-http
This file contains 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
//http://doc.akka.io/docs/akka/2.4.3/scala/http/routing-dsl/directives/security-directives/authenticateBasic.html | |
Object Routes { | |
path("basicauthtest"){ | |
authenticateBasic(realm = "secure site", BasicAuthenticator.myUserPassAuthenticator) { user => | |
complete { | |
HttpResponse(entity = HttpEntity("SUCCESS")) | |
} | |
} | |
} | |
} | |
Object BasicAuthenticator { | |
private val hardCodedPassword = "qwerty" //For example purposes only | |
def myUserPassAuthenticator(credentials: Credentials): Option[String] = credentials match { | |
case [email protected](id) if p.verify(hardCodedPassword) => Some(id) | |
case _ => None | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment