2016-07-29 42 views
1

我用邮差4.4.1在Chrome 51.0.2704.63.I已经成立了一个的tomcat6 web项目,在web.xml,如:邮差摘要授权请求返回401 Unauthrized

<web-app> 
    <display-name>Archetype Created Web Application</display-name> 
    <security-constraint> 
     <web-resource-collection> 
      <web-resource-name> 
       My App 
      </web-resource-name> 
      <url-pattern>/*</url-pattern> 
     </web-resource-collection> 
     <auth-constraint> 
      <role-name>tomcat</role-name> 
     </auth-constraint> 
    </security-constraint> 

    <login-config> 
     <auth-method>DIGEST</auth-method> <!-- DIGEST here --> 
     <realm-name>My Realm</realm-name> 
    </login-config> 
</web-app> 

当我访问http://localhost:8080/simple-web/使用我的本地浏览器,弹出一个窗口让我输入用户名和密码。填好后,效果很好。 当我使用邮递员时,我在授权页面中输入用户名和密码,然后选择带有Digest Auth的类型。它总是向我显示401 Unauthrized。 我可以看到头:

Cache-Control →no-cache 
Content-Length →954 
Content-Type →text/html;charset=utf-8 
Date →Fri, 29 Jul 2016 10:26:20 GMT 
Expires →Thu, 01 Jan 1970 08:00:00 CST 
Pragma →No-cache 
Server →Apache-Coyote/1.1 
WWW-Authenticate →Digest realm="My Realm", qop="auth", nonce="dcb71e7d6766f85c3f233b7b74e42423", opaque="4894d1ece1380278a451585e9b548e21" 

能有人知道的原因,以及如何解决它?

回答

0

从一开始我就用Digest Authentication的两步过程构建请求,从Firebug构建请求并发送它,并获取401将nonce,有时不透明复制到摘要字段并重新发送以获得成功。 关于论坛的讨论使我相信它仍然是一个问题。我正在使用5.1.2 Windows App。 我将我在Firebug中看到的最初请求建模,当我粘贴网址并获取预期响应时。