简体   繁体   English

HTTP摘要式身份验证

[英]HTTP Digest Authentication

I want to use HTTP Digest Authentication with a central database that stores usernames and encrypted passwords. 我想将HTTP摘要式身份验证与存储用户名和加密密码的中央数据库一起使用。 These data should be used by different servers like Apache httpd or Tomcat for example. 这些数据应该由不同的服务器使用,例如Apache httpd或Tomcat。 The clients will be humans with browsers and other applications communicating in a RESTful way. 客户端将是人类,浏览器和其他应用程序以RESTful方式进行通信。

As far as I understand I could not use a table with hashed passwords. 据我所知,我无法使用带有散列密码的表。 It is only possibly to store HA1 = MD5(username:realm:password) where a clear text password is required - correct? 只能存储HA1 = MD5(用户名:域名:密码) ,其中需要明文密码 - 对吗?

On the other hand it seems to be possible to use hashed passwords with Apache httpd: 另一方面,似乎可以在Apache httpd中使用散列密码:

Apache httpd doc says: Apache httpd doc说:

The first column value of the first row returned by the query statement should be a string containing the encrypted password. 查询语句返回的第一行的第一列值应该是包含加密密码的字符串。

Does it work with digest authentication? 它是否适用于摘要式身份验证? There is no parameter to specify the hash algorithm. 没有参数来指定哈希算法。 How does Apache httpd decide which algorithm to use? Apache httpd如何决定使用哪种算法?

RFC 2617 says: RFC 2617说:

4.13 Storing passwords 4.13存储密码

Digest authentication requires that the authenticating agent (usually the server) store some data derived from the user's name and password in a "password file" associated with a given realm. 摘要式身份验证要求身份验证代理(通常是服务器)将从用户名和密码派生的一些数据存储在与给定领域关联的“密码文件”中。 Normally this might contain pairs consisting of username and H(A1), where H(A1) is the digested value of the username, realm, and password as described above. 通常,这可能包含由用户名和H(A1)组成的对,其中H(A1)是如上所述的用户名,领域和密码的消化值。

It sounds like the password has to be clear text. 听起来密码必须是明文。

The Servlet 3.0 spec says: Servlet 3.0规范说:

Although passwords are not sent on the wire, HTTP Digest authentication requires that clear text password equivalents be avaialble to the authenticating container so that it can validate received authenticators by calculating the expected digest. 虽然密码不是通过线路发送的,但HTTP摘要身份验证要求对验证容器提供明文密码等效,以便它可以通过计算预期的摘要来验证收到的验证者。

What is the "clear text password equivalent" here? 这里的“明文密码等价”是什么? The password hash? 密码哈希?

Tomcat documentation says: Tomcat文档说:

If using digested passwords with DIGEST authentication, the cleartext used to generate the digest is different. 如果使用带有DIGEST身份验证的消化密码,则用于生成摘要的明文不同。 In the examples above {cleartext-password} must be replaced with {username}:{realm}:{cleartext-password}. 在上面的示例中,{cleartext-password}必须替换为{username}:{realm}:{cleartext-password}。 For example, in a development environment this might take the form testUser:localhost:8080:testPassword. 例如,在开发环境中,这可能采用testUser:localhost:8080:testPassword的形式。

Here is a clear text password required. 这是一个需要明文密码。

So, can HTTP Digest authentication be used with already encrypted passwords or have the passwords to be clear text? 那么,HTTP摘要身份验证是否可以与已加密的密码一起使用,或者密码是否为明文?

Must the user re-enter his credentials if he requests a page from a different subdomain? 如果用户请求来自其他子域的页面,用户是否必须重新输入其凭据?

Does the browser delete the cached password when the tab is closed or only when the whole is closed? 选项卡关闭时或仅当整个选项卡关闭时,浏览器是否会删除缓存的密码? Maybe this differs from browser to browser - I'd be interested in which browser delete it and which keep it. 也许这在浏览器与浏览器之间有所不同 - 我对哪个浏览器删除它以及保留它有兴趣。

The overall question is, whether digest authentication is suitable for my scenario with a central user db with already encrypted passwords. 总体问题是,摘要式身份验证是否适用于具有已加密密码的中央用户数据库的情况。 Or should I better use session based single sign on service? 或者我应该更好地使用基于会话的单点登录服务?

In this scenario where you have already a database of hashed passwords it's not possible to use digest authentication as far as they were not hashed using the same function. 在这种已经存在散列密码数据库的情况下,只要不使用相同的函数进行散列,就不可能使用摘要式身份验证。

I think the best solution for you here is create a login page and use cookie sessions to control the privileges of the users. 我认为这里最好的解决方案是创建一个登录页面并使用cookie会话来控制用户的权限。 With this solution you get the answer for the other questions: 使用此解决方案,您可以获得其他问题的答案:

i think you can hash the user inputted password first with the same function used to store the passwords in the database, then pass it as a digest password and the rest of the procedure will be the same. 我认为您可以首先使用与在数据库中存储密码相同的函数来散列用户输入的密码,然后将其作为摘要密码传递,其余过程将相同。

and you will have to pass username and password in the HTTP URL instead of the normal form http://www.rojotek.com/blog/2008/05/19/http-authentication-in-a-url/ 你必须在HTTP URL而不是普通表格中传递用户名和密码http://www.rojotek.com/blog/2008/05/19/http-authentication-in-a-url/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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