Java Play 2.3.x 中的身份验证

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24140660/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 10:26:32  来源:igfitidea点击:

Authentication in Play 2.3.x

javaauthenticationplayframeworkplayframework-2.0

提问by Danish Khan

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.

我正在使用播放!framework v2.3 (Java) 并且我想向我的 web 应用程序添加一些用户身份验证,即每个用户的用户名/密码和注册过程。

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/JavaGuide4https://www.playframework.com/documentation/2.2.x/JavaGuide4

我在有关如何为 v2.1 和 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).

但是我找不到有关 v2.3 的任何更新信息。我已经尝试查看 play.mvc.Security.Authenticated 的 API,但它没有帮助(http://www.playframework.com/documentation/2.3.x/api/java/play/mvc/Security. Authenticated.html)。

Anyone know how to do this properly?

有谁知道如何正确地做到这一点?

采纳答案by Michael Zajac

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)

安全社交- 这似乎是最受欢迎的,有很多文档。(对于java和scala)

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

Deadbolt 2- 有许多从该 git 存储库链接的实现示例。它似乎更适合java。

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

Play2 Auth- 这仅适用于 Scala,但它有据可查且非常灵活。(我个人使用 Play2 Auth)

回答by Eric M.

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

我们公司发布了一个开源云平台即服务 Web UI(适用于 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.

我们计划在接下来的几周内将它迁移到 2.3.X,尽管我们一开始有一些不兼容的问题,我们需要考虑一下。

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.

您可以在http://www.acentera.com/opensource/ 上观看我们工作的短视频;从那里您将能够找到我们的代码的公共 Git 存储库,在某些情况下需要改进,但希望可以成为您使用这个伟大的 Web 框架的良好开端。

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.

我们使用 shiro 作为身份验证,使用自定义“SampleRealm”进行 JDBC 身份验证并获得适当的“权限”,使用 memcache 作为会话存储以保持无状态连接。

Regards, Eric M. ACenterA Inc.

此致, Eric M. ACenterA Inc.

回答by Danish Khan

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

我找到了这个 Play 模板,其中包括登录、重置密码等...

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

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

回答by user3770276

Out there is another greate authentication library called Silhouettefor 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

还有另一个强大的身份验证库,称为Silhouettefor Play Framework 应用程序(Scala),它支持多种身份验证方法,包括 OAuth1、OAuth2、OpenID、凭据、基本身份验证、双因素身份验证或自定义身份验证方案。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

它维护得很好,几天前发布了稳定版 3.0.0: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.

最酷的是,该项目以虚构的犯罪斗士角色剪影命名,来自守望者图画小说和电影。

回答by cyril

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

播放身份验证开始不仅适用于 Scala,也适用于 Java,它嵌入了死锁……社会安全,无状态,有很多例子:

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

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

it is the best customizable authentication module to use

它是最好的可定制身份验证模块