Authentication in Play 2.3.x
Asked Answered
C

5

24

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?

Cynth answered 10/6, 2014 at 12:11 Comment(0)
K
23

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)

Kunstlied answered 10/6, 2014 at 16:24 Comment(2)
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.Epergne
Does anyone have step by step instructions for installing Secure Social on a existing project that was done in play 2.3.8?Alphabetical
S
9

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.

Superstar answered 30/7, 2015 at 10:0 Comment(1)
A demonstration seed template for play 2.4 with angularJS can be found here: github.com/mohiva/play-silhouette-angular-seedTrainband
C
7

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

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

Cynth answered 11/6, 2014 at 10:49 Comment(0)
F
0

Our company have published an OpenSource Cloud Platform As a Service Web UI (for Play Framework 2.2.2).

We are planning to migrate it to 2.3.X over the next few weeks, even though we had some incompatibility at first that we need to look at.

You can view short video's of our work at http://www.acentera.com/opensource/ ; from there you will be able to find our Public Git Repository of the code, which in some cases need improvements but hopefully can be a good start for you to use this great web framework.

We used shiro as authentication with a custom "SampleRealm" that does the JDBC Authentication and get proper "permissions", with memcache as sessions store in order to keep stateless connections.

Regards, Eric M. ACenterA Inc.

Flagman answered 10/6, 2014 at 14:28 Comment(3)
The views and the controllers have not been checked in. Thanks.Cynth
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.Flagman
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.Flagman
J
0

Play authenticate is since beginning not only for scala but for java too, it have deadbolt embedded... Social secure, stateless with plenty of examples :

https://github.com/joscha/play-authenticate

it is the best customizable authentication module to use

Jail answered 15/10, 2016 at 8:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.