差異處
這裏顯示兩個版本的差異處。
下次修改 | 前次修改 | ||
pc:security:authentication:digest_authentication [2014/11/18 14:09] tony 建立 |
pc:security:authentication:digest_authentication [2023/06/25 09:48] (目前版本) |
||
---|---|---|---|
行 1: | 行 1: | ||
+ | {{tag>security spring}} | ||
====== Digest Authentication ====== | ====== Digest Authentication ====== | ||
+ | ===== Sequence ===== | ||
+ | - Client對Resource發存取請求。 | ||
+ | - Server回應Header WWW-Authenticate: Digest realm、qop、nonce與Opaque。 | ||
+ | - Client以realm、nonce與Opaque做驗證。 | ||
+ | - Server回應驗證結果。 | ||
+ | * realm: 提示user此resource該輸入的account與password。 | ||
+ | * qop: quality of protection,決定驗證字串的表達方式。步驟二中,server應提供所支援的方式,包含auth與auth-int。 | ||
+ | * nonce: 用於某次請求的字串。可能是個timestamp。 | ||
+ | * opaque: 詳細用途不曉得。根據rfc2617中表達內容,像是一種server的metadata。 | ||
+ | |||
+ | 步驟三中,在給server request header中的response ,會根據qop而有所不同。可參考[[http://en.wikipedia.org/wiki/Digest_access_authentication|link]]中的Overview。另外附加的nonceCount與clientNonce,是由client所控制決定,用來避免Chosen Plaintext attacks。Server可根據內容決定驗證結果。\\ | ||
+ | \\ | ||
+ | 在spring-securiry-web 3.2.5版本中,僅支援qop=auth,其中nonceCount與clientNonce只要與response對得起來,並不會另外做特別驗證。 | ||
+ | |||
+ | ===== Client Tool的使用 ===== | ||
+ | ==== cURL ==== | ||
+ | <code bash> | ||
+ | curl --digest -u "user:passwd" http://request_url | ||
+ | </code> | ||
+ | ==== Postman ==== | ||
+ | 與cURL最大差別在於要發兩次request,一次是為了拿nonce,一次是驗證並拿回結果。 | ||
+ | - 針對resource的URL發一次request。 | ||
+ | - 從header內容中拿取realm與nonce。如果有opaque也要拿出來用。 | ||
+ | - 填至Digest Auth表單中,並點擊Refresh headers。Postman會自動幫你算出response內容。 | ||
+ | - 發出請求。 | ||
===== Reference ===== | ===== Reference ===== | ||
* [[http://zh.wikipedia.org/wiki/Nonce|Nonce]] | * [[http://zh.wikipedia.org/wiki/Nonce|Nonce]] | ||
* [[http://msdn.microsoft.com/en-us/library/cc239682.aspx|Digest Authentication]] | * [[http://msdn.microsoft.com/en-us/library/cc239682.aspx|Digest Authentication]] | ||
* [[http://en.wikipedia.org/wiki/Digest_access_authentication|Digest Access Authentication]] | * [[http://en.wikipedia.org/wiki/Digest_access_authentication|Digest Access Authentication]] | ||
+ | * [[http://www.hkpug.net/2009/02/18/%E7%94%A8-php-%E5%AF%A6%E7%8F%BE-http-%E8%BA%AB%E4%BB%BD%E9%A9%97%E8%AD%89/|用 PHP 實現 HTTP 身份驗證]] | ||
+ | * [[https://security.stackexchange.com/questions/165982/http-digest-authentication-does-the-server-store-plaintext-passwords|HTTP Digest Authentication: Does the server store plaintext passwords?]] |