0
现在我建立一个REST API CORS在Tomcat的8这是使用Apache的CorsFilter允许跨域请求,我设置为我的web.xml这样运行:摘要式身份验证与Tomcat的
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/webapi/*</url-pattern>
</filter-mapping>
到目前为止,这么简单,我想为我的Rest-API添加一个DIGEST认证,是的,不是基本的!
对于简单的用法我想在web.xml中使用安全约束:
<security-constraint>
<web-resource-collection>
<web-resource-name>all</web-resource-name>
<url-pattern>/webapi/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>DIGEST</auth-method>
<realm-name>UserDatabase</realm-name>
</login-config>
身份验证和CORS滤镜上有自己的优秀,但在这里开始的问题: 安全约束在CORS过滤器之前由servlet容器执行。 因此,验证算法不会在摘要式验证标头中设置所需的CORS(跨域请求标头),因此CORS请求在验证时将失败,因为含有“challange”的摘要401页(nonce,qop ,领域等)缺少跨域请求所需的头文件。 现在是否有人为此问题提供解决方案或实现?或者我真的需要实现我自己的摘要过滤器,因为CORS?!