当前位置:网站首页>Configuring Apache digest authentication
Configuring Apache digest authentication
2022-06-26 12:33:00 【Edison Dont】
Apache Common user authentication can be divided into the following three types :
- be based on IP, Access control of subnets (ACL)
- Basic user authentication (Basic Authentication)
- Message digest authentication (Digest Authentication)
Message digest authentication (Digest Authentication)
Digest Authentication Extended security over basic authentication . The server generates a unique random number for each connection , The client will use this random number to set the password MD5 encryption , Then send it to the server , The server also encrypts the password with this random number , And then compare it with the encrypted data sent by the client .
1. Send a page access request
Request URL:http://localhost/config/
Request method:GET
2. Web The server requires user credentials to be entered in a book ( Server return 401 Response head and ’realm’ Domain )
HTTP/1.1 401 Unauthorized
Date: Tue, 01 Jun 2021 07:17:51 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1;mode=block
WWW-Authenticate: Digest realm="Digest Encrypt", nonce="C9zdI6/DBQA=b6e73f0db8e3966873cc961fc22031b43e02aab6", algorithm=MD5, qop="auth"
Content-Length: 381
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1
3. The browser pops up a login window ( contain ’realm’), User name is required / password
4. Request after entering user name and password
Host: localhost
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Authorization: Digest username="Admin", realm="Digest Encrypt", nonce="C9zdI6/DBQA=b6e73f0db8e3966873cc961fc22031b43e02aab6", uri="/config/", algorithm=MD5, response="ae7dc868b37313788a24d2e6e0094154", qop=auth, nc=00000001, cnonce="001945ca0da1ba75"
5. The server compares the encrypted credentials entered by the user with the encrypted credentials of the server , If consistent, return the response of the requested page
HTTP/1.1 200 OK
Date: Tue, 01 Jun 2021 08:26:28 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1;mode=block
Authentication-Info: rspauth="a04006ede76a798709c2ea1c5c7533bb", cnonce="777276a0e05dcab9", nc=00000002, qop=auth
Content-Length: 5089
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html;charset=UTF-8
To configure Apache
1. Create password file
htdiget [-c] passwordfile realm username
D:\Softwares\Apache24\bin> htdigest.exe -c \ "Digest Encrypt" Admin
Adding password for Admin in realm Digest Encrypt.
New password: ********
Re-type new password: ********
-c = create file
Do not use for regular addition -c Options ,, Because it will overwrite the existing file .
File content format :Admin:Digest Encrypt:ded139b4abeb56c14a30ff0a07e27010
2. To configure httpd.conf
# The 'AuthName' and the 'Realm' must be the same (BASIC validation can be different).
# Otherwise correct user password still will not pass the authentication.
<Directory "${DocumentRoot}\config">
Options Indexes FollowSymLinks
AuthType Digest
AuthName "Digest Encrypt"
AuthUserFile "D:\digest.txt"
require valid-user
AllowOverride None
</Directory>
3. Authentication module configuration
see httpd.conf Is there any
LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule auth_basic_module modules/mod_auth_basic.so
First of all, make sure you have mod_auth_digest.so, This is not necessary to recompile apache.
Second, make sure that mod_auth_basic.so This line is commented out . because apache The default is to use basic To certify , If not annotated , Even if configured digest authentication , It's not going to work . Only one of the two authentication methods can be selected .
WWW-Authenticate Response Header
If a server receives a request for an access-protected object, and an acceptable Authorization header is not sent, the server responds with a "401 Unauthorized" status code, and a WWW-Authenticate header as per the framework defined above, which for the digest scheme is utilized as follows.
If the server receives a request to access the protected object , And no acceptable authorization header was sent , The server will "401 unauthorized " Status codes and WWW-Authenticate Header as response .
challenge = "Digest" digest-challenge digest-challenge = 1#( realm | [ domain ] | nonce | [ opaque ] |[ stale ] | [ algorithm ] | [ qop-options ] | [auth-param] ) domain = "domain" "=" <"> URI ( 1*SP URI ) <"> URI = absoluteURI | abs_path nonce = "nonce" "=" nonce-value nonce-value = quoted-string opaque = "opaque" "=" quoted-string stale = "stale" "=" ( "true" | "false" ) algorithm = "algorithm" "=" ( "MD5" | "MD5-sess" | token ) qop-options = "qop" "=" <"> 1#qop-value <"> qop-value = "auth" | "auth-int" | token
scheme | explain |
---|---|
realm | A string displayed to the user , So they know which username and password to use . This string should contain at least the name of , It may also include a collection of users that represent possible permissions . example :"[email protected]". |
nonce | Every time the server makes 401 Unique data string generated in response . nonce Opaque to the client . |
Reference link
1. The WWW-Authenticate Response Header
边栏推荐
- One click deployment of your own community forum
- 2021 q3-q4 investigation report on the use status of kotlin multiplatform
- Omnichannel membership - tmall membership 1: opening tutorial
- SQL injection
- PHP calculates excel coordinate values, starting with subscript 0
- Msvcr110 not found DLL, unable to continue code execution Solution for startup
- Ubuntu安装配置PostgreSQL(18.04)
- 开通证券账户需要注意事项 开户安全吗
- Investment planning and forecast report on the future direction of China's smart agriculture during the 14th five year plan (2022)
- dried food! Yiwen will show you SD card, TF card and SIM card!
猜你喜欢
[solved] data duplication or data loss after laravel paginate() paging
SQL injection in Pikachu shooting range
Laravel+gatewayworker completes the im instant messaging and file transfer functions (Chapter 4: server debugging errors)
Implementing mixins scheme in applet
Mysql8 master-slave replication
International beauty industry giants bet on China
11、 Box styles and user interface
Comparison of latest mobile phone processors in 2020 (with mobile phone CPU ladder diagram)
Jmeter响应时间和tps监听器使用教程
2、 MySQL Foundation
随机推荐
How to do well in member marketing three steps to teach you to understand member management
24 database interview questions that must be mastered!
Oracle lock table query and unlocking method
Research on the current situation of China's modified engineering plastics market and demand forecast analysis report 2022-2028
SQL injection
Lintcode 130 · stacking
TP5 thinkphp5 extension package think Mongo operation mongodb time interval range query
Scala-day06- pattern matching - Generic
2、 MySQL Foundation
Analysis report on China's photovoltaic inverter market prospect forecast and investment strategy recommendations in 2022
初探Protostuff的使用[通俗易懂]
女性科学家的流失
China Medical Grade hydrogel market supply and demand research and prospect analysis report 2022 Edition
Basic principle of MOS tube and important knowledge points of single chip microcomputer
What should I do from member labels to portraits?
Analysis report on the "fourteenth five year plan" and investment prospect of China's pharmaceutical equipment industry 2022-2028
File decryption in webgame development
7-3 最低通行费
Spark-day03-core programming RDD operator
Implementing mixins scheme in applet