IIS中常见的几种验证模式如Anonymous,Bisic,Digest,Windows Authentication验证过程剖析

Basic Authentication:

step1:

客户端以anonymouse验证方式请求服务

step2:

服务器接收到request后,在其Http header中指明其authentication mode,为basic authentication,从而要求客户端提供有效的credential, 其header 格式如下图所示,同时返回401给客户端

step3:

客户端接受到服务器返回的response后,从其header中得知其authentication mode为basic authentication, 故在客户端弹出相应对话框,要求输入username&Password,形成有效的client credential,并将该credential以明文的形式写在http header中,传送至server.

step4:

server接受到该request之后,从header中提取有效的client credential,并对该credential进行有效性验证。如果通过,则开始process the request.否则,返回401给客户端。

Note:在对client credential中进行验证时候,不一定需要domain environment。在IIS7中,我们可以自定义一个basic authentication module来进行credential的有效性验证。

Digest Authentication

step1:

客户端以anonymouse验证方式请求服务

step2:

服务器接收到request后,在其Http header中指明其authentication mode为Digest authentication,从而要求客户端提供有效的credential, 并指定对client提供的credential产生消息摘要的算法,如下图中所示为MD5算法。其header 格式如下图所示,同时返回401给客户端。

因此,Digest authentication是看不到client所提供的password,只能看到对其credential产生的消息摘要,即使被截获,这些对于第3方是毫无意义的。这样相对于basic authentication的明文传输credential要安全多。

step3:

客户端接受到服务器返回的response后,从其header中得知其authentication mode为digest authentication, 故在客户端弹出相应对话框,要求输入username&Password,形成有效的client credential,并将该credential通过消息摘要机密算法对其加密写入http  header,然后连同请求传送至server.此时发送出去的包如下图所示: 

 step4:

server接受到该request之后,从header中提取有效的client credential,并通过LDAP服务,连接至DC,查找相应用户名与摘要信息匹配的domain user。如果找到,说明该 credential 有效,则开始process the request.否则,返回401给客户端。

 

Integrated windows Authentication

step1:

客户端以anonymouse验证方式请求服务

step2:

服务器接收到request后,在其Http header中指明其authentication mode为integrated windows authentication, 其header 格式如下图所示,同时返回401给客户端。 integrated windows authentication有2种方式,分别为NTLM和kerberos验证,而Negotiate方式实际为NTLM和Kerberos的Wrapper. 优先条件下使用kerberos验证。

step3:

通过制定的Kerberos或者NTLM验证模式,验证客户提供的TGS是否有效。如果通过,则处理该请求。否则,放回401

原文地址:https://www.cnblogs.com/Winston/p/1371976.html