Authentication in Play 2.3.x

16,698

Solution 1

There are a number of authentication libraries that already exist which cover many use cases. It'd be best to use something that's well established in the community.

Secure Social - This seems to be the most popular, with lots of documentation. (For both java and scala)

Deadbolt 2 - There are many implementation examples linked from that git repo. It seems a little more geared for java.

Play2 Auth - This is for scala only, but it is well documented and very flexible. (I personally use Play2 Auth)

Solution 2

Out there is another greate authentication library called Silhouette for Play Framework applications (Scala) that supports several authentication methods, including OAuth1, OAuth2, OpenID, Credentials, Basic Authentication, Two Factor Authentication or custom authentication schemes. http://silhouette.mohiva.com

It is very well maintained and the stable version 3.0.0 got announced just a couple days ago: http://silhouette.mohiva.com/blog/stable-release-of-silhouette-300

The cooles thing is, the project is named after the fictional crime fighter character Silhouette, from the Watchmen graphic novel and movie.

Solution 3

I found this Play template which covers logging in, resetting password, etc...

https://typesafe.com/activator/template/PlayStartApp

Share:
16,698

Related videos on Youtube

Danish Khan
Author by

Danish Khan

Updated on June 04, 2022

Comments

  • Danish Khan
    Danish Khan almost 2 years

    I'm using the Play! framework v2.3 (Java) and I want to add some user authentication to my web app, ie username/password for each user and a registration process.

    I found some information on the docs on how to do this for v2.1 and v2.2: http://www.playframework.com/documentation/2.1.0/JavaGuide4 https://www.playframework.com/documentation/2.2.x/JavaGuide4

    But I can't find any updated info on v2.3. I've already tried looking at the API for play.mvc.Security.Authenticated but it doesn't help (http://www.playframework.com/documentation/2.3.x/api/java/play/mvc/Security.Authenticated.html).

    Anyone know how to do this properly?

  • Danish Khan
    Danish Khan almost 10 years
    The views and the controllers have not been checked in. Thanks.
  • Eric M.
    Eric M. almost 10 years
    It actually not a "normal play application". In the sense that it is using EmberJS Framework. The views are inside the handlebars templates URL : Handlebars Views and all the data is sent over JSON API's calls.
  • Eric M.
    Eric M. almost 10 years
    Also, you can see in the following Project Controller It uses : if (SecurityController.canViewUser(projectId, userId)) { Not the best way of doing, but it can be an example.
  • Patrick Hammer
    Patrick Hammer over 9 years
    at my company, we use Secure Social since over a year. Now we just upgraded to play 2.3. The official release of securesocial for 2.3 is not out yet, but there is a release candidate which we already use. So far, it looks stable and nicely working. I can really recommend SecureSocial, but have to say that I never really integrated the other ones.
  • pitchblack408
    pitchblack408 about 9 years
    Does anyone have step by step instructions for installing Secure Social on a existing project that was done in play 2.3.8?
  • OliverKK
    OliverKK almost 9 years
    A demonstration seed template for play 2.4 with angularJS can be found here: github.com/mohiva/play-silhouette-angular-seed