Closed
Description
SPT Developer opened SPR-13691 and commented
I am using my original CORS interceptor and dispatching OPTIONS request for pre-flight.
servlet.setDispatchOptionsRequest(true);
After upgraded Spring Boot to 1.3.0 RC1 with Spring 4.2.2, Spring CORS intercepted my original. In order to disable Spring CORS, I added CorsUtils in my classpath temporary.
package org.springframework.web.cors;
import javax.servlet.http.HttpServletRequest;
/**
* CORS utility (Overriding)
*/
public class CorsUtils {
/**
* Returns {@code true} if the request is a valid CORS one.
*/
public static boolean isCorsRequest(HttpServletRequest request) {
// Disable Spring CORS by force.
return false;
}
/**
* Returns {@code true} if the request is a valid CORS pre-flight one.
*/
public static boolean isPreFlightRequest(HttpServletRequest request) {
// Disable Spring CORS by force.
return false;
}
}
To fix it permanently, please add option to swith on/off Spring CORS.
if (!enableSpringCors || !CorsUtils.isCorsRequest(request)) {
......
- https://github.com/spring-projects/spring-framework/blob/v4.2.2.RELEASE/spring-web/src/main/java/org/springframework/web/filter/CorsFilter.java#L83
- https://github.com/spring-projects/spring-framework/blob/v4.2.2.RELEASE/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java#L365
if (enableSpringCors && CorsUtils.isCorsRequest(request)) {
......
if (this.dispatchOptionsRequest || (enableSpringCors && CorsUtils.isPreFlightRequest(request))) {
......
- https://github.com/spring-projects/spring-framework/blob/v4.2.2.RELEASE/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java#L368
- https://github.com/spring-projects/spring-framework/blob/v4.2.2.RELEASE/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java#L218
if (enableSpringCors && CorsUtils.isPreFlightRequest(request)) {
......
Affects: 4.2.2
Issue Links:
- CORS support in 4.2 - default or configure to OFF [SPR-14049] #18621 CORS support in 4.2 - default or configure to OFF ("is duplicated by")
- DefaultCorsProcessor's origin comparison is restrictive and inefficient [SPR-14080] #18652 DefaultCorsProcessor's origin comparison is restrictive and inefficient
- Enable/Disable CORS revisited [SPR-17598] #22130 Enable/Disable CORS revisited
0 votes, 5 watchers