当前位置:网站首页>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
边栏推荐
- China Medical Grade hydrogel market supply and demand research and prospect analysis report 2022 Edition
- TP5 thinkphp5 report serialization of'closure'is not allowed
- Common problems and Thoughts on member operation management
- Jmeter响应时间和tps监听器使用教程
- A most practical arbitrage wizard EA [2022 modified version]
- Basic principle of MOS tube and important knowledge points of single chip microcomputer
- Seven major trends deeply affecting the U.S. consumer goods industry in 2022
- Omnichannel membership - tmall membership 2: frequently asked questions
- Analysis report on the "fourteenth five year plan" and investment prospect of China's pharmaceutical equipment industry 2022-2028
- [redis series] redis learning 16. Redis Dictionary (map) and its core coding structure
猜你喜欢

PHP laravel+gatewayworker completes im instant messaging and file transfer (Chapter 1: basic configuration)
![[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure](/img/d2/a6cbb0abe9e04c412d1f6021430528.png)
[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure

11、 Box styles and user interface

环形队列php
![[probability theory] conditional probability, Bayesian formula, correlation coefficient, central limit theorem, parameter estimation, hypothesis test](/img/2f/f44381ea759f4c1c957a8f9434f0ee.png)
[probability theory] conditional probability, Bayesian formula, correlation coefficient, central limit theorem, parameter estimation, hypothesis test

TP5 thinkphp5 report serialization of'closure'is not allowed

nvm安装教程

Spark-day03-core programming RDD operator

Fengshentai old shooting range Kali series

dried food! Yiwen will show you SD card, TF card and SIM card!
随机推荐
Omnichannel membership - tmall membership 2: frequently asked questions
Current situation investigation and investment prospect forecast analysis report of China's electrolytic copper market from 2022 to 2028
Five trends of member marketing of consumer goods enterprises in the future
What software is flush? Is online account opening safe?
Jsonarray and jsonobject of fastjson [easy to understand]
Msvcr110 not found DLL, unable to continue code execution Solution for startup
Jmeter响应时间和tps监听器使用教程
Investment planning and forecast report on the future direction of China's smart agriculture during the 14th five year plan (2022)
Redis cannot connect to the server through port 6379
PHP uses laravel pay component to quickly access wechat jsapi payment (wechat official account payment)
How long ago did PHP get
Ubuntu安装配置PostgreSQL(18.04)
What determines the rent
On the use of protostaff [easy to understand]
Generate JDE dot train
一个初级多线程服务器模型
【毕业季·进击的技术er】忆毕业一年有感
Laravel uses find_ IN_ The set() native MySQL statement accurately queries whether a special string exists in the specified string to solve the problem that like cannot be accurately matched. (resolve
How to do well in member marketing three steps to teach you to understand member management
Iframe usage and contentwindow, parent and PostMessage communication methods