使用 bcrypt 对密码进行哈希处理时的 Web 应用程序身份验证

发布于 2024-09-05 14:41:58 字数 198 浏览 4 评论 0原文

我创建了一个需要身份验证的 GWT 项目。最初,用户的密码是纯文本形式,但现在我想用 BCrypt 对它们进行哈希处理。我进行了搜索,但找不到描述如何使 Jetty 针对 BCrypt 哈希密码进行身份验证的地方。

我使用纯文本格式并通过 SSL 将密码发送到服务器。我需要做什么才能使 Jetty 散列此密码并将其与数据库中的密码进行比较?

谢谢;

I created a GWT project which requires authentication. Initially, the users' passwords were in plain text, but now I would like to hash them with BCrypt. I searched but I cannot find a place describing how to make Jetty authenticate against a BCrypt hashed password.

I'm sending the password to the server using a FORM in plain text and over SSL. What do I need to do to make Jetty hash this password and compare it to the one in the database?

Thank you;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷荒 2024-09-12 14:41:58

在 JAAS 中,这是由 LoginModule 完成的。 Jetty 特定的 JAAS 教程(我实际上只是浏览了一下)解释了,如何可以实现您自己的,并配置 Jetty 来使用它。

正如 Igor 在他链接的帖子中指出和解释的那样,仅靠容器会话管理不足以防御 XSRF。您仍然可以使用 JAAS - 但请确保您的服务器调用另外受到存储在 cookie 中的令牌的保护。

我个人会使用与 cookie 中使用的令牌不同的令牌。这有助于防止 XSS(否则,您将无法达到 httpOnly cookie)。

In JAAS, this is done by a LoginModule. The Jetty-specific JAAS tutorial (which I actually just glanced over) explains, how you can implement your own, and configure Jetty to use it.

As Igor already noted and explained in the post he linked to, the container session management alone won't be good enough to defend against XSRF. You can still use JAAS - but make sure, that your server calls are additionally protected by a token that's not stored in a cookie.

I would personally use a different token than the one used in the cookie. This helps to protect a little bit against XSS (otherwise, you would defeat the purpose of httpOnly cookies).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文