標籤:html asi whether symlink identity username content employee 資訊
Digest access authentication
https://en.wikipedia.org/wiki/Digest_access_authentication
Digest access authentication is one of the agreed-upon methods a web server can use to negotiate credentials, such as username or password, with a user‘s web browser. This can be used to confirm the identity of a user before sending sensitive information, such as online banking transaction history. It applies a hash function to the username and password before sending them over the network. In contrast, basic access authentication uses the easily reversible Base64 encoding instead of encryption, making it non-secure unless used in conjunction with SSL.
Technically, digest authentication is an application of MD5 cryptographic hashing with usage of nonce values to prevent replay attacks. It uses the HTTP protocol.
Authentication
https://en.wikipedia.org/wiki/Authentication
Authentication (from Greek: α?θεντικ?ς authentikos, "real, genuine", from α?θ?ντης authentes, "author") is the act of confirming the truth of an attribute of a single piece of data (a datum) claimed true by an entity. In contrast with identification which refers to the act of stating or otherwise indicating a claim purportedly attesting to a person or thing‘s identity, authentication is the process of actually confirming that identity. It might involve confirming the identity of a person by validating their identity documents, verifying the authenticity of a website with a digital certificate,[1] determining the age of an artifact by carbon dating, or ensuring that a product is what its packaging and labeling claim to be. In other words, authentication often involves verifying the validity of at least one form of identification.
認證就是確定身份的過程。
Identification (psychology)
https://en.wikipedia.org/wiki/Identification_%28psychology%29
Identification is a psychological process whereby the subject assimilates an aspect, property, or attribute of the other and is transformed, wholly or partially, by the model the other provides. It is by means of a series of identifications that the personality is constituted and specified. The roots of the concept can be found in Freud‘s writings. The three most prominent concepts of identification as described by Freud are: primary identification, narcissistic (secondary) identification and partial (secondary) identification.[1]
While "in the psychoanalytic literature there is agreement that the core meaning of identification is simple - to be like or to become like another", it has also been adjudged ‘"the most perplexing clinical/theoretical area" in psychoanalysis‘.[2]
Authorization
https://en.wikipedia.org/wiki/Authorization
‘Authorization‘ is the function of specifying access rights to resources related to information security and computer security in general and to access control in particular. More formally, "to authorize" is to define an access policy. For example, human resources staff is normally authorized to access employee records and this policy is usually formalized as access control rules in a computer system. During operation, the system uses the access control rules to decide whether access requests from (authenticated) consumers shall be approved (granted) or disapproved (rejected). Resources include individual files or an item‘s data, computer programs, computer devices and functionality provided by computer applications. Examples of consumers are computer users, computer Softwares and other Hardware on the computer.
授權是在認證之前, 將資源分派給不同的使用者角色。
digest報文詳解
http://blog.csdn.net/andrewpj/article/details/45727853
-
伺服器核實使用者身份
server收到client的HTTP request(INVITE),如果server需要用戶端摘要認證,就需要產生一個摘要盤問(digest challenge),通過Response給client一個401 Unauthorized狀態發送給使用者。
摘要盤問如 圖二 中的WWW-Authenticate header所示:
摘要盤問中的各個參數意義如下:
-
realm(領域):必須的,在所有的盤問中都必須有。它是目的是鑒別SIP訊息中的機密。在實際應用中,它通常設定為server所負責的網域名稱。
-
nonce (現時):必須的,這是由伺服器規定的資料字串,在伺服器每次產生一個摘要盤問時,這個參數都是不一樣的(與前面所產生的不會雷同)。nonce 通常是由一些資料通過md5雜湊運算構造的。這樣的資料通常包括時間標識和伺服器的機密短語。確保每個nonce 都有一個有限的生命期(也就是過了一些時間後會失效,並且以後再也不會使用),而且是獨一無二的(即任何其它的伺服器都不能產生一個相同的nonce )。
-
Stale:不必須,一個標誌,用來指示用戶端先前的請求因其nonce值到期而被拒絕。如果stale是TRUE(大小寫敏感),用戶端可能希望用新的加密回應重新進行請求,而不用麻煩使用者提供新的使用者名稱和口令。伺服器端只有在收到的請求nonce值不合法,而該nonce對應的摘要(digest)是合法的情況下(即用戶端知道正確的使用者名稱/口令),才能將stale置成TRUE值。如果stale是FALSE或其它非TRUE值,或者其stale域不存在,說明使用者名稱、口令非法,要求輸入新的值。
-
opaque(不透明體):必須的,這是一個不透明的(不讓外人知道其意義)資料字串,在盤問中發送給使用者。
-
algorithm(演算法):不必須,這是用來計算雜湊的演算法。當前只支援MD5演算法。
-
qop(保護的品質):必須的,這個參數規定伺服器支援哪種保護方案。用戶端可以從列表中選擇一個。值 “auth”表示只進行身份查驗, “auth-int”表示進行查驗外,還有一些完整性保護。需要看更詳細的描述,請參閱RFC2617。
- 用戶端反饋使用者身份
client 產生 產生摘要響應(digest response),然後再次通過 http request (INVITE (Withink digest))發給 server。
摘要響應如 圖三 中的Authenticate header所示:
摘要響應中的各個參數意義如下:
- username: 不用再說明了
- realm: 需要和 server 盤問的realm保持一致
-
nonce:用戶端使用這個“現時”來產生摘要響應(digest response),需要和server 盤問中攜帶的nonce保持一致,這樣伺服器也會在一個摘要響應中收到“現時”的內容。伺服器先要檢查了“現時”的有效性後,才會檢查摘要響應的其它部分。
因而,nonce 在本質上是一種標識符,確保收到的摘要機密,是從某個特定的摘要盤問產生的。還限制了摘要盤問的生命期,防止未來的重播攻擊。
-
qop:用戶端選擇的保護方式。
-
nc (現時計數器):這是一個16進位的數值,即用戶端發送出請求的數量(包括當前這個請求),這些請求都使用了當前請求中這個“現時”值。例如,對一個給定的“現時”值,在響應的第一個請求中,用戶端將發送“nc=00000001”。這個指示值的目的,是讓伺服器保持這個計數器的一個副本,以便檢測重複的請求。如果這個相同的值看到了兩次,則這個請求是重複的。
-
response:這是由使用者代理程式軟體計算出的一個字串,以證明使用者知道口令。比如可以通過 username、password、http method、uri、以及nonce、qop等使用MD5加密產生。
-
cnonce:這也是一個不透明的字串值,由用戶端提供,並且用戶端和伺服器都會使用,以避免用明文文本。這使得雙方都可以查驗對方的身份,並對訊息的完整性提供一些保護。
-
uri:這個參數包含了用戶端想要訪問的URI。
- server 確認使用者
確認使用者主要由兩部分構成:
- 檢查nonce的有效性
- 檢查摘要響應中的其他資訊, 比如server可以按照和用戶端同樣的演算法產生一個response值,和client傳遞的response進行對比。
http://www.cnblogs.com/jcli/archive/2012/12/11/2812459.html
Digest的流程和上面一樣,只是challenge和digest的產生演算法不同
- 在瀏覽器請求:http://localhost:8080/index.html
- 伺服器返回401(unauthentication)代碼,並附帶一個包含challenge的頭,格式如下:WWW-Authenticate Digest realm="Admin All", qop="auth", nonce="1354760194666:4465c7b1921b6d769fd359e5152c453f", opaque="EE9C283E89AFB63E7FF6E2C04C524807"
- 瀏 覽器用MD5編碼後的資訊添加到要求標頭中再次請求1中的資源,如果使用者名稱是tomcat,密碼是tomcat,則產生的頭資訊:Authorization Digest username="tomcat", realm="Admin All", nonce="1354760194666:4465c7b1921b6d769fd359e5152c453f", uri="/web/index.html", response="8d30e6438636fe21c6045246dd034372", opaque="EE9C283E89AFB63E7FF6E2C04C524807", qop=auth, nc=00000001, cnonce="9201a828891792b9"
- 用3中計算的要求標頭資訊再次請求1中的資源
- 伺服器用3中相同的演算法(base64)驗證使用者密碼合法性
- 返回index.html的資源
linux安裝apache httpd 配置digest
http://www.cnblogs.com/rainisic/archive/2012/05/23/Linux_Apache2_4_Install.html
Linux下安裝Apache 2.4
http://blog.jobbole.com/41519/
Step 1: 建立密碼檔案
文法:
htdiget [-c] passwordfile realm username/usr/local/apache/bin> ./htdigest -c /data/www/auth/digest/ "Digest Encrypt" LengWaAdding password for LengWa in realm "Digest Encrypt" .New password:Re-type new password:
| 123456 |
htdiget [-c] passwordfile realm username /usr/local/apache/bin> ./htdigest -c /data/www/auth/digest/ "Digest Encrypt" LengWaAdding password for LengWa in realm "Digest Encrypt" .New password:Re-type new password: |
-c = create file
常規添加不要使用-c選項, 因為它會覆蓋現有的檔案.
設定檔案所有權和許可權(root可以進行讀寫, Apache Group只可以讀取)
/data/www/auth/digest/ > ls -l -rw-r----- 1 root httpd ... user.txt
| 12 |
/data/www/auth/digest/ > ls -l-rw-r----- 1 root httpd ... user.txt |
user.txt格式: LengWa:Digest Encrypt:d95ea4412b0fb517b25c4c46f32e5a2b
Step2: 配置httpd.conf
<Directory "/data/www/auth/digest"> Options Indexes FollowSymLinks AuthType Digest AuthName "Digest Encrypt" //注意這裡的AuthName和上面的realm必須一致(而Basic驗證則可以不同). 否則你輸入正確的使用者密碼也無法通過認證 AuthDigestProvider file AuthUserFile /data/www/auth/digest/user.txt require valid-user</Directory>
| 12345678 |
<Directory "/data/www/auth/digest"> Options Indexes FollowSymLinks AuthType Digest AuthName "Digest Encrypt" //注意這裡的AuthName和上面的realm必須一致(而Basic驗證則可以不同). 否則你輸入正確的使用者密碼也無法通過認證 AuthDigestProvider file AuthUserFile /data/www/auth/digest/user.txt require valid-user</Directory> |
現在基於Digest的驗證環境就搭建好了.
注: 在Basic驗證中. 我使用了.htaccess 而在Digest驗證中我沒有使用. 只是為了個人的需要. 你可以根據自己需要進行配置.
http://liwei521930.blog.163.com/blog/static/515217082010112462152253/
有一些so庫依賴, 配置httpd.conf
digest認證需要依賴cookie識別用戶端
http://itangqi.me/2016/04/07/the-notes-of-learning-illustrating-http-three/
基於表單認證需要依賴cookie在用戶端識別使用者, 入:
依賴cookie識別用戶端是限制, 是否digest認證可以避免這種限制呢?
分析digest認證, 其中 nonce貌似可以用作session id, 如中的nonce。
原理上是可行的, 但是經過抓包分析, nonce值在未登入前, 每次訪問URL,響應的nonce值都是變化的,如果將nonce作為session id, 則未登入時候, 設定攻擊訪問情境, 則會建立很多會話,導致背景灰化很容易滿了。
cookie sid作為會話ID:
1、 將鑒權和會話分離,職責分明。 鑒權方式 digest form basic, 僅僅負責鑒權。 會話還是由cookie sid管理。
2、 利用cookie識別使用者, 不會產生上述描述, 會話被未訪問報文攻擊, 導致很快就滿的情況。
第一次nonce:
第二次nonce:
實驗
第一次訪問資源:
第二次訪問資源, nonce一樣, 但是授權資訊 response不一樣:
http 登入Digest認證相關知識