简体   繁体   中英

Authentication in Play 2.3.x

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?

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)

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.

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

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM