Incorporating Login/ Authentication into Play 2.x
For people in hurry here is the code and the steps.
In continuation of Play 2.x (Scala) is it a Spring MVC contender? – Introduction, in this blog, I will demonstrate how to extend Security.Authenticated standard Play API to implement basic authentication in your application.
As a first step, I will extend this class to implement a Security trait as below,
As provided in the comment section it is clear what each method does. Next step is to plumb the login steps refer Application.scala as below,
Finally the CoffeesController.scala where we need to override onUnauthorized method and put the IsAuthenticated block in each action as below,
To test if authentication worked, start play,
And when you type the url http://localhost:9000/coffee, you get…
View original post 24 more words