http 登录Digest认证相关知识

2023-05-16

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。

      1. 客户端反馈用户身份

      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。

      1. server 确认用户
        确认用户主要由两部分构成:
    • 检查nonce的有效性
    • 检查摘要响应中的其他信息, 比如server可以按照和客户端同样的算法生成一个response值,和client传递的response进行对比。

 

http://www.cnblogs.com/jcli/archive/2012/12/11/2812459.html

 

Digest的流程和上面一样,只是challenge和digest的生成算法不同

  1. 在浏览器请求:http://localhost:8080/index.html
  2. 服务器返回401(unauthentication)代码,并附带一个包含challenge的头,格式如下:WWW-Authenticate    Digest realm="Admin All", qop="auth", nonce="1354760194666:4465c7b1921b6d769fd359e5152c453f", opaque="EE9C283E89AFB63E7FF6E2C04C524807"
  3. 浏 览器用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"
  4. 用3中计算的请求头信息再次请求1中的资源
  5. 服务器用3中相同的算法(base64)验证用户密码合法性
  6. 返回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" LengWa Adding password for LengWa in realm "Digest Encrypt" . New password: Re-type new password:
1
2
3
4
5
6
htdiget [-c] passwordfile realm username
 
/usr/local/apache/bin> ./htdigest -c /data/www/auth/digest/ "Digest Encrypt" LengWa
Adding 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
1
2
/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>
1
2
3
4
5
6
7
8
<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不一样:

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

http 登录Digest认证相关知识 的相关文章

随机推荐

  • SpringCloud使用Prometheus监控(基于Eureka)

    本文介绍SpringCloud使用Prometheus xff0c 基于Eureka服务发现 1 Prometheus介绍 在之前写过两篇有关Prometheus使用的文章 xff0c 如下 xff1a SpringBoot使用promet
  • 服务器搭建网站完整教程

    服务器最大的用途 xff0c 就是可以搭建网站 xff0c 许多人都认为搭建网站是一件很难的事情 xff0c 因为包含许多的比较专业东西 xff0c 比如服务器 编程之类的 xff0c 确实 xff0c 在几年前是这样的 xff0c 普通人
  • cs231n 作业1 心路历程

    cs231n Assignment 1 cww note 做cs231n的作业的一个心路历程 xff0c 不会重复别人写好的材料 xff0c 别人写的数学分析 xff0c 代码 xff0c 比我高到不知道哪里去了 We are here 这
  • VMware vSphere 6 序列号大全

    转载自 http www i5i6 net post 190 html vSphere 6 Hypervisor HY0XH D508H 081U8 JA2GH CCUM2 4C4WK 8KH8L H85J0 UHCNK 8CKQ8 NV0
  • 一元线性回归模型--总体回归模型与样本回归模型

    2019独角兽企业重金招聘Python工程师标准 gt gt gt 总体回归函数 xff08 population regression function xff0c 简称 PRF xff09 将总体被解释变量 Y 的 条件均值表现为解释变
  • Mac百度网盘下载慢怎么办?Mac百度网盘下载满速教程

    Mac百度网盘是不少用户常用的云存储的工具 xff0c 但是很多用户经常抱怨下载速度慢 xff0c 那么Mac百度网盘下载慢怎么办 xff1f Mac百度网盘下载慢怎么解决 xff1f 一起去了解一下吧 Mac百度网盘下载满速教程 xff1
  • inner join,outer join,left join,right join的区别

    外联接 外联接可以是左向外联接 右向外联接或完整外部联接 在 FROM 子句中指定外联接时 xff0c 可以由下列几组关键字中的一组指定 xff1a LEFT JOIN 或 LEFT OUTER JOIN 左向外联接的结果集包括 LEFT
  • 【Java】生成UUID

    import java util UUID public class MainProcess public static void main String args UUID uuid 61 UUID randomUUID System o
  • racket

    let 和 let 区别 这是对的 let x random 4 o random 4 diff number gt string abs x o cond gt x o string append 34 X wins by 34 diff
  • 文本挖掘分词mapreduce化

    软件版本 paoding analysis3 0 项目jar包和拷贝庖丁dic目录到项目的类路径下 修改paoding analysis jar下的paoding dic home properties文件设置词典文件路径 paoding
  • IP网络号的指派范围

    上一篇 xff0c IP分类 http blog csdn net friendan article details 8449048 网络类别 最大可指派的网络数 第一个可指派的网络号 最后一个可指派的网络号 每个网络中的最大主机数 A类
  • 卷积神经网络不能处理“图”结构数据?这篇文章告诉你答案

    本文要介绍的这一篇paper是ICML2016上一篇关于 CNN 在图 xff08 graph xff09 上的应用 ICML 是机器学习方面的顶级会议 xff0c 这篇文章 lt lt Learning CNNs for Graphs g
  • cs231n 作业2 心路历程

    Assignments 2 作业说明在这里 Fully connected Neural Network 今天写的时候思考了一下为什么课件里写的都是 W x 43 b Wx 43 b W x 43 b
  • 加域时提示指定的网络名不再可用

    加域时提示指定的网络名不再可用 发布于 2011 06 10 由 alefwoo 没有评论 发表评论 VMware虚机加入域时提示 xff1a 指定的网络名不再可用 能够正常解析出域名 xff0c 能够ping通 xff0c 提示指定的网络
  • ONOS之开放分布式SDN操作系统

    为什么80 的码农都做不了架构师 xff1f gt gt gt 关于构建ONOS xff08 开放式网络操作系统 xff09 的项目专题 xff0c 是通过性能激发创建的实验性分布式 SDN 控制平台 xff0c 满足大型运营商网络的可扩展
  • Linux网络唤醒软件,Linux网络唤醒

    在Linux下 xff0c 当机器处于睡眠或待机状态时 xff0c 想通过网络进行唤醒 WOL xff0c wake on lan 时 xff0c 可以通过如下相关命令来实现 xff1a 在A机 嵌入式设备 上 xff0c 让其睡眠 xff
  • Maven常用命令:

    Maven库 xff1a http repo2 maven org maven2 Maven依赖查询 xff1a http mvnrepository com 一 xff0c Maven常用命令 xff1a 1 创建Maven的普通Java
  • Lodash 源码大全

    这个文章的意义在于 想学习loadsh的所有源码 从github的顺序开始看 严格按照顺序的 xff0c 所以难免有集合函数数组这样的跳跃 loadsh很多运算我们也可以写出来 xff0c 但是严谨性可复用性却没有loadsh强 是分界线
  • 最优化-可行方向法

    Zoutendijk可行方向法 约束条件一般有两种 ax b 61 0 ax b lt 61 0 取可行初始点x1 x1满足所有的约束条件 取约束条件中所有 lt 61 0 的约束条件 xff0c 并判断他们是否为0 获得线性规划子问题 一
  • http 登录Digest认证相关知识

    Digest access authentication https en wikipedia org wiki Digest access authentication Digest access authentication is on